-
Notifications
You must be signed in to change notification settings - Fork 0
IPoolable
Andrés Eduardo Maldonado edited this page Jun 14, 2019
·
4 revisions
Public interface.
Interface with events from the Pooling System, use this if you want to execute code at spawn/unspawn from the pool.
NOTE: IPoolable should be used by a MonoBehaviour (or a child of) and preferably be on the root of the prefab.
public class ExampleScript : MonoBehaviour, IPoolable
{
private int counter;
public void OnPoolSpawn()
{
counter++;
Debug.Log("I've been spawned " + counter + "times!");
}
public void OnPoolUnSpawn()
{
// Other events here.
}
}
Returns | Name | Description |
---|---|---|
void | OnPoolSpawn | Called when the object is taken out from the pool. |
void | OnPoolUnSpawn | Called before the object needs to go back to the pool. |