public static void Return(PoolableObject instance) { if (instance == null) { return; } if (Instance == null) { Debug.LogError("Cannot return to pool, pool instance is null!"); return; } int id = instance.PrefabID; instance.Despawn(); if (Instance.Drain) { if (Instance.drain.ContainsKey(id)) { Instance.drain[id] = 0f; } else { Instance.drain.Add(id, 0f); } } instance.gameObject.SetActive(false); instance.transform.SetParent(GetGroup(id).transform, !instance.IsUI); Ensure(id); Instance.pool[id].Enqueue(instance); }