RexPool

RexPool is a simple spawn pool class. It pools objects to be reused, letting you recycle them instead of calling Instantiate() and Destroy(), and thus increases performance. It should be used for things which are constantly spawned, like bullets or hit sparks.

Public Methods

public GameObject Spawn()

Spawns the object slotted into the “prefab” slot in the Inspector and returns the resulting GameObject.

public void Despawn(GameObject _object)

If this is passed a GameObject which this RexPool spawned, this will deactivate the GameObject and return it to the RexPool to be reused later.

public int ActiveObjects()

This returns the number of currently active GameObjects which this RexPool has spawned.

Public Members

public GameObject prefab

The prefab that will be spawned.

public int startingPoolSize

The amount of the prefab Instantiated in Start(). This only references the starting amount of the prefab; the RexPool will spawn more if they are requested.