public PoolableMonoBehaviour GetPoolableObject(PoolableMonoBehaviour original) { int instanceID = original.GetInstanceID(); PoolableMonoBehaviour objectToReturn = null; if (_pooledObjectDictionary.ContainsKey(instanceID)) { Queue <PoolableMonoBehaviour> poolableQueue = _pooledObjectDictionary[instanceID]; if (poolableQueue.Count > 0) { objectToReturn = poolableQueue.Dequeue(); } } if (objectToReturn == null) { objectToReturn = MonoBehaviour.Instantiate(original); } objectToReturn.SetActive(true); objectToReturn.SetOriginalInstanceId(original); return(objectToReturn); }
public void SetOriginalInstanceId(PoolableMonoBehaviour original) { OriginalInstanceId = original.GetInstanceID(); }