public static void Despawn(GameObject obj) { PoolMember pm = obj.GetComponent <PoolMember>(); if (pm == null) { GameObject.Destroy(obj); } else { pm.myPool.Despawn(obj); } }
/// <summary> /// Despawn the specified gameobject back into its pool. /// </summary> static public void Despawn(GameObject obj) { PoolMember pm = obj.GetComponent <PoolMember>(); if (pm == null) { Debug.Log("Object '" + obj.name + "' wasn't spawned from a pool. Destroying it instead."); GameObject.Destroy(obj); } else { pm.myPool.Despawn(obj); } }