Exemple #1
0
 void Awake()
 {
     activePool         = new Dictionary <PooledName, List <Poolable> >();
     unactivePool       = new Dictionary <PooledName, List <Poolable> >();
     getPooledEvent    += GetPooledObject;
     returnPooledEvent += ReturnPooledObject;
     foreach (PooledObject o in objectsToPool)
     {
         List <Poolable> temp = new List <Poolable>();
         for (int i = 0; i < o.startCount; i++)
         {
             Poolable obj = (Poolable)Instantiate(o.instance);
             obj.gameObject.SetActive(false);
             obj.Reset();
             temp.Add(obj);
         }
         unactivePool.Add(o.name, temp);
         activePool.Add(o.name, new List <Poolable>());
     }
 }
Exemple #2
0
 public void OnDestroy()
 {
     getPooledEvent    -= GetPooledObject;
     returnPooledEvent -= ReturnPooledObject;
 }