Show / Hide Table of Contents

    Class Spawner

    Spawner which can instantiate one prefab object in the scene

    Inheritance
    Object
    Spawner
    Namespace: i5.Toolkit.Core.Spawners
    Assembly: cs.temp.dll.dll
    Syntax
    public class Spawner : MonoBehaviour

    Fields

    destroyWithSpawner

    Declaration
    protected bool destroyWithSpawner
    Field Value
    Type Description
    Boolean

    maxNumberOfInstances

    Declaration
    protected int maxNumberOfInstances
    Field Value
    Type Description
    Int32

    overwriteExistingInstances

    Declaration
    protected bool overwriteExistingInstances
    Field Value
    Type Description
    Boolean

    prefab

    Declaration
    protected GameObject prefab
    Field Value
    Type Description
    GameObject

    spawnedInstanceQueue

    Declaration
    protected Queue<GameObject> spawnedInstanceQueue
    Field Value
    Type Description
    Queue<GameObject>

    spawnOnAwake

    Declaration
    protected bool spawnOnAwake
    Field Value
    Type Description
    Boolean

    Properties

    DestroyWithSpawner

    If true, the spawned instance will be destroyed if the spawner is destroyed

    Declaration
    public bool DestroyWithSpawner { get; set; }
    Property Value
    Type Description
    Boolean

    MostRecentlySpawnedObject

    Returns the most recently spawned object

    Declaration
    public GameObject MostRecentlySpawnedObject { get; }
    Property Value
    Type Description
    GameObject

    OverwriteExistingInstances

    If true, multiple calls of Spawn() will destroy existing instances in the scene Otherwise Spawn() will only work if no instance exists in the scene

    Declaration
    public bool OverwriteExistingInstances { get; set; }
    Property Value
    Type Description
    Boolean

    SpawnedInstances

    The instance which was created by this spawner

    Declaration
    public GameObject[] SpawnedInstances { get; }
    Property Value
    Type Description
    GameObject[]

    Methods

    Awake()

    Initiates a spawn if spawnOnAwake is true

    Declaration
    protected virtual void Awake()

    OnDestroy()

    Called if the spawner is destroyed. If destroyWithSpawner was checked, the spawned instance will also be destroyed

    Declaration
    protected virtual void OnDestroy()

    Setup(GameObject)

    This method can be overwritten to setup the spawned instance immediately after it has been created

    Declaration
    protected virtual void Setup(GameObject instance)
    Parameters
    Type Name Description
    GameObject instance

    Spawn()

    Spawns the object instance Note that the spawn may fail, e.g. if the instance already existed and may not be overwritten

    Declaration
    public bool Spawn()
    Returns
    Type Description
    Boolean

    True if the spawn process was successful

    Back to top i5 Toolkit Documentation