public static void ReturnObjectToPool(PooledMonoBehaviour instance) { int id = instance.PrefabId; if (s_PooledObjects.TryGetValue(id, out Queue <PooledMonoBehaviour> queue)) { queue.Enqueue(instance); } else { Queue <PooledMonoBehaviour> newQueue = new Queue <PooledMonoBehaviour>(); newQueue.Enqueue(instance); s_PooledObjects[id] = newQueue; } instance.transform.parent = Instance.transform; }
public static void ReturnObjectToPool(PooledMonoBehaviour instance) { int id = instance.PrefabId; if (s_PooledObjects.TryGetValue(id, out Queue <PooledMonoBehaviour> queue)) { queue.Enqueue(instance); } else { Queue <PooledMonoBehaviour> newQueue = new Queue <PooledMonoBehaviour>(); newQueue.Enqueue(instance); s_PooledObjects[id] = newQueue; } instance.transform.parent = Instance.transform; //Наш объект всегда выключен, поэтому и все его дети тоже выключены }