public PoolableObject Get() { // These extra instantiations during initialization are to populate pools that will be used a lot later if (PoolManager.i.initializing) { int count = usedObjectsCount; for (int i = unusedObjectsCount; i < Mathf.Min(count * PREWARM_ACTIVE_MULTIPLIER, maxPrewarmCount); i++) { Instantiate(); } Instantiate(); } else if (unusedObjects.Count == 0) { Instantiate(); } PoolableObject poolable = Extract(); EnablePoolableObject(poolable); poolable.OnPoolGet(); return(poolable); }
public PoolableObject Get() { if (PoolManager.i.initializing) { int count = usedObjectsCount; for (int i = unusedObjectsCount; i < Mathf.Min(count * PREWARM_ACTIVE_MULTIPLIER, maxPrewarmCount); i++) { Instantiate(); } Instantiate(); } else if (unusedObjects.Count == 0) { Instantiate(); } PoolableObject poolable = Extract(); EnablePoolableObject(poolable); poolable.OnPoolGet(); return(poolable); }