AddOnCreatedDelegate( class poolName, OnCreatedDelegate createdDelegate)
Added in PoolManager 5.5.0
Pass a C# method to be run when the SpawnPool is created and available for use. This is known as an event delegate.
This solves a common issue in Unity where you have code in Awake() which runs before PoolManager's Awake causing an "pool does not exist" error.
To use this, in your Awake() method, register a separate method to be triggered by PoolManager when the Pool is created. The name of the method doesn't matter. Only the method "signature" has to match. That is, the method's arguments are required to match what PoolManager's delegate expects; in this case a single argument of type ' SpawnPool'.
Here is a complete example, which is also included in the example Scripts folder with demo scene.
public class OnCreatedDelegateExample : MonoBehaviour
PoolManager.Pools.AddOnCreatedDelegate("Audio", this.RunMe);
public void RunMe(SpawnPool pool)
Debug.Log("Delegate ran for pool " + pool.poolName);
|