logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class UnitySpawnFactory

    Unity implementation of ISpawnFactory using GameObjects.

    Inheritance
    object
    UnitySpawnFactory
    Implements
    IRecyclingSpawnFactory
    ISpawnFactory
    Namespace: Serenity.GameSpawner.Infrastructure.Factories
    Assembly: Serenity.UnityGameSpawner.Infrastructure.dll
    Syntax
    public class UnitySpawnFactory : MonoBehaviour, IRecyclingSpawnFactory, ISpawnFactory
    Remarks

    Creates empty GameObjects as spawned entity containers. Implements IRecyclingSpawnFactory so the spawner service can park and resume instances by toggling UnityEngine.GameObject.SetActive(System.Boolean) instead of destroying and recreating them. Game-specific implementations can override this factory to use prefabs, object pools, or other instantiation strategies.

    Constructors

    UnitySpawnFactory()

    Declaration
    public UnitySpawnFactory()

    Fields

    _instances

    Declaration
    protected readonly Dictionary<SpawnHandle, GameObject> _instances
    Field Value
    Type Description
    Dictionary<SpawnHandle, GameObject>

    Methods

    Create(SpawnType)

    Declaration
    public virtual SpawnHandle Create(SpawnType type)
    Parameters
    Type Name Description
    SpawnType type
    Returns
    Type Description
    SpawnHandle

    Deactivate(SpawnHandle)

    Declaration
    public virtual bool Deactivate(SpawnHandle handle)
    Parameters
    Type Name Description
    SpawnHandle handle
    Returns
    Type Description
    bool

    Destroy(SpawnHandle)

    Declaration
    public virtual void Destroy(SpawnHandle handle)
    Parameters
    Type Name Description
    SpawnHandle handle

    DestroyAll(SpawnType)

    Declaration
    public virtual void DestroyAll(SpawnType type)
    Parameters
    Type Name Description
    SpawnType type

    Reactivate(SpawnHandle)

    Declaration
    public virtual bool Reactivate(SpawnHandle handle)
    Parameters
    Type Name Description
    SpawnHandle handle
    Returns
    Type Description
    bool

    Implements

    IRecyclingSpawnFactory
    ISpawnFactory
    In this article
    © 2026 Serenity. All Rights Reserved