logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class UnityGameSpawnerService

    Unity MonoBehaviour implementation of IGameSpawnerService.

    Inheritance
    object
    UnityGameSpawnerService
    Implements
    IGameSpawnerService
    IService
    IFoundationSettings
    Namespace: Serenity.GameSpawner.Infrastructure.Services
    Assembly: Serenity.UnityGameSpawner.Infrastructure.dll
    Syntax
    public class UnityGameSpawnerService : MonoBehaviour, IGameSpawnerService, IService, IFoundationSettings
    Remarks

    Delegates entity creation and destruction to an ISpawnFactory. Tracks instances per spawn type through a PoolBucket. When the factory also implements IRecyclingSpawnFactory, despawned instances are parked and reused instead of destroyed; otherwise every despawn destroys.

    Constructors

    UnityGameSpawnerService()

    Declaration
    public UnityGameSpawnerService()

    Fields

    LOG_CATEGORY

    Declaration
    protected const string LOG_CATEGORY = "GameSpawnerService"
    Field Value
    Type Description
    string

    _bucketsByType

    Declaration
    protected readonly Dictionary<SpawnType, PoolBucket> _bucketsByType
    Field Value
    Type Description
    Dictionary<SpawnType, PoolBucket>

    _factory

    Declaration
    protected ISpawnFactory _factory
    Field Value
    Type Description
    ISpawnFactory

    _guid

    Declaration
    protected string _guid
    Field Value
    Type Description
    string

    _id

    Declaration
    protected string _id
    Field Value
    Type Description
    string

    _logService

    Declaration
    protected ILogService _logService
    Field Value
    Type Description
    ILogService

    Properties

    Guid

    Declaration
    public string Guid { get; set; }
    Property Value
    Type Description
    string

    Id

    Declaration
    public string Id { get; set; }
    Property Value
    Type Description
    string

    LogService

    Declaration
    public ILogService LogService { get; set; }
    Property Value
    Type Description
    ILogService

    Methods

    Despawn(SpawnHandle)

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

    DespawnAll()

    Declaration
    public virtual void DespawnAll()

    DespawnAll(SpawnType)

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

    GetPoolState(SpawnType)

    Declaration
    public virtual PoolStateSnapshot GetPoolState(SpawnType type)
    Parameters
    Type Name Description
    SpawnType type
    Returns
    Type Description
    PoolStateSnapshot

    InitializeService(ILogService, ISpawnFactory)

    Initializes the service with required dependencies.

    Declaration
    public virtual void InitializeService(ILogService logService, ISpawnFactory factory)
    Parameters
    Type Name Description
    ILogService logService

    The logging service for diagnostic output.

    ISpawnFactory factory

    The spawn factory for entity creation and destruction.

    IsActive(SpawnHandle)

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

    Spawn(SpawnType)

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

    Implements

    IGameSpawnerService
    IService
    IFoundationSettings
    In this article
    © 2026 Serenity. All Rights Reserved