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>()); } }
public void OnDestroy() { getPooledEvent -= GetPooledObject; returnPooledEvent -= ReturnPooledObject; }