Class Spawner
Spawner which can instantiate one prefab object in the scene
Assembly: cs.temp.dll.dll
public class Spawner : MonoBehaviour
Fields
Declaration
protected bool destroyWithSpawner
Field Value
Declaration
protected int maxNumberOfInstances
Field Value
Declaration
protected bool overwriteExistingInstances
Field Value
Declaration
protected GameObject prefab
Field Value
Type |
Description |
GameObject |
|
Declaration
protected Queue<GameObject> spawnedInstanceQueue
Field Value
Type |
Description |
Queue<GameObject> |
|
Declaration
protected bool spawnOnAwake
Field Value
Properties
If true, the spawned instance will be destroyed if the spawner is destroyed
Declaration
public bool DestroyWithSpawner { get; set; }
Property Value
Returns the most recently spawned object
Declaration
public GameObject MostRecentlySpawnedObject { get; }
Property Value
Type |
Description |
GameObject |
|
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
The instance which was created by this spawner
Declaration
public GameObject[] SpawnedInstances { get; }
Property Value
Type |
Description |
GameObject[] |
|
Methods
Initiates a spawn if spawnOnAwake is true
Declaration
protected virtual void Awake()
Called if the spawner is destroyed.
If destroyWithSpawner was checked, the spawned instance will also be destroyed
Declaration
protected virtual void OnDestroy()
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 |
|
Spawns the object instance
Note that the spawn may fail, e.g. if the instance already existed and may not be overwritten
Declaration
Returns
Type |
Description |
Boolean |
True if the spawn process was successful
|