Skip to content

Documentation

Venomous edited this page Oct 16, 2018 · 26 revisions

How to setup UnityObjectPooler in your Unity project?

Step 1).

Add ObjectPool.cs to your project assets folder.


Step 2).

Use the ObjectPool's static methods

ObjectPool can be accessed at all times.

ObjectPool.Clear(); // Clears the pool (should be used on scene reload or new scene load because its static)

ObjectPool.Add(poolable); // Takes IPoolable type so any class that inherits IPoolable interface can be passed

ObjectPool.Get<yourtype>(); // Will return one of your type from the pool (null if none in the pool)

ObjectPool.GetCustom<yourtype>(customlambda); // This will return your IPoolable to the type passed if one is found based on your custom lambda criteria

ObjectPool.GetAmountInPool<yourtype>(); // Retrieves an int based on how many of this type are in the pool

Clone this wiki locally