/// <summary> /// Despawn pooled game object. /// </summary> /// <param name="poolable">Pooled game object</param> public void Despawn(GameObject poolable, params object[] args) { // Loop over all pooled prefabs. for (int i = 0; i < Prefabs.Length; i++) { // Check if current pool is same as current object. if (Prefabs[i].Prefab.name == poolable.name) { // Add to pool again. pool[i].Add(poolable); // If it has a pool script, fire it's OnDespawn event. Poolable p = poolable.GetComponent <Poolable>(); if (p != null) { p.OnDespawn(args); } else { poolable.SetActive(false); } return; } } }