public void Push(PoolObject poolObject) { if (m_GameObjectPoolDataDetails.PoolName.Equals(poolObject.PoolName)) { if (m_StackObject.Contains(poolObject)) { Debug.LogWarning("Trying to return already pooled object '" + poolObject.gameObject.name + "' to pool."); } else { AddObjectToPool(poolObject); } } else { Debug.LogError( "Trying to add object '" + poolObject.gameObject.name + "' to incorrect pool (" + poolObject.PoolName + " | " + m_GameObjectPoolDataDetails.PoolName + "." ); } }
private void AddObjectToPool(PoolObject poolObject) { poolObject.gameObject.SetActive(false); m_StackObject.Push(poolObject); poolObject.IsPooled = true; }