Use the method ObjectPoolManager.Instance.DisposePool(); to empty the pool
Remember that only the objects marked as Disposable will be destroyed
To hard flush the pool, removing every single object, use a boolean parameter ObjectPoolManager.Instance.DisposePool(true);
IPoolable interface
Optionally, the prefab script can implement IPoolable interface
This way, every time it's instance is retrieved or recycled, the methods Retrieve() and Recycle() will be fired respectively.
using UnityEngine;using ObjectPool;publicclassCubeBehaviour:MonoBehaviour,IPoolable{publicvoidRetrieve(){
print("Object Retrieved");}publicvoidRecycle(){
print("Object Recycled");}}
Managed Update
When working with a great amount of objects, it's considered a good practice to center each individual Update() into a single behaviour in order to optimize performance
ObjectPoolManager is also able to concentrate instanced objects updates, just extend IManagedUpdate interface
It's possible to combine IPoolable and IManagedUpdate interfaces
using UnityEngine;using ObjectPool;publicclassCubeBehaviour:MonoBehaviour,IPoolable,IManagedUpdate{publicvoidRetrieve(){
ObjectPoolManager.Instance.RegisterManagedUpdate(this);}publicvoidRecycle(){
ObjectPoolManager.Instance.UnregisterManagedUpdate(this);}publicvoidManagedUpdate(floatdeltaTime){
print(deltaTime);}}