static T FetchObjectFromPoolEntry(FreePoolEntry <T> poolEntry) { T obj = poolEntry.GetObjectFromPool(); ActivateObject(obj); return(obj); }
static FreePoolEntry <T> GetPoolEntryFor(T prefab) { if (!assetPool.ContainsKey(prefab.name)) { FreePoolEntry <T> entry = new FreePoolEntry <T> (prefab); assetPool.Add(prefab.name, entry); } return(assetPool [prefab.name]); }
public override bool Equals(object obj) { eComp = obj as FreePoolEntry <U>; if (eComp == null) { return(false); } return(eComp.GetHashCode() == GetHashCode()); }
public static void Destroy(T instantiatedObject) { if (poolingEnabled && instantiatedObject.ShouldPoolObject()) { FreePoolEntry <T> poolEntry = GetPoolEntryFor(instantiatedObject); DeactivateObject(instantiatedObject); poolEntry.AddObjectToPool(instantiatedObject); } else { DestroyObject(instantiatedObject); } }
public static T Instantiate(T prefab) { if (poolingEnabled && prefab.ShouldPoolObject()) { FreePoolEntry <T> poolEntry = GetPoolEntryFor(prefab); if (poolEntry.IsPoolEmpty()) { INSTANTIATE_COUNT++; return(InstantiatePrefab(prefab)); } else { POOL_RETRIEVAL_COUNT++; return(FetchObjectFromPoolEntry(poolEntry)); } } else { return(InstantiatePrefab(prefab)); } }