コード例 #1
0
        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);
        }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
 public PooledConnection(PooledInstance <string> pooledInstance, T connection)
 {
     this.pooledInstance = pooledInstance;
     this.connection     = connection;
 }