public void Add(CustomPool <T> pPool) { if (!poolDict.ContainsKey(pPool.Prefab.GameObjectId())) { poolDict.Add(pPool.Prefab.GameObjectId(), pPool); } else { var pool = poolDict[pPool.Prefab.GameObjectId()]; //Merge two pool foreach (var obj in pPool.ActiveList) { if (!pool.ActiveList.Contains(obj)) { pool.ActiveList.Add(obj); } } foreach (var obj in pPool.InactiveList) { if (!pool.InactiveList.Contains(obj)) { pool.InactiveList.Add(obj); } } } }
public CustomPool <T> Add(T pPrefab) { if (!poolDict.ContainsKey(pPrefab.GameObjectId())) { var pool = new CustomPool <T>(pPrefab, mInitialNumber, container.transform, !pPrefab.gameObject.IsPrefab()); poolDict.Add(pPrefab.GameObjectId(), pool); } else { Debug.Log($"Pool Prefab {pPrefab.name} has already existed!"); } return(poolDict[pPrefab.GameObjectId()]); }
public CustomPool <T> Get(T pPrefab) { if (poolDict.ContainsKey(pPrefab.GameObjectId())) { return(poolDict[pPrefab.GameObjectId()]); } else { var pool = new CustomPool <T>(pPrefab, mInitialNumber, container.transform, !pPrefab.gameObject.IsPrefab()); poolDict.Add(pPrefab.GameObjectId(), pool); return(pool); } }