PooledInstance CreateInstance(GameObject prefab, Stack <PooledInstance> pool) { var g = GameObject.Instantiate(prefab); g.SetActive(false); var p = new PooledInstance() { gameObject = g, pool = pool, instanceKey = g.GetInstanceID() }; instances[p.instanceKey] = p; return(p); }
static void _Return(PooledInstance pi, bool invokeCallback) { if (pi.refCount == 1) { pi.refCount--; if (invokeCallback && pi.callback != null) { pi.callback.Invoke(pi.gameObject); } pi.callback = null; pi.gameObject.SetActive(false); Instance.pendingReturns.Remove(pi); pi.pool.Push(pi); } }
public PooledConnection(PooledInstance <string> pooledInstance, T connection) { this.pooledInstance = pooledInstance; this.connection = connection; }