public ObjectPool <T> GetObjPoolWithType <T>(OBJ_POOL_TYPE type) where T : Component { ObjectPoolObj obj = null; ObjectPool <T> objPool = null; if (objPoolWithCompDict.TryGetValue(type, out obj)) { objPool = (ObjectPool <T>)obj.GetComponent <ObjectPoolObj>().objPool; return(objPool); } return(objPool); }
public ObjectPool <T> LoadObjPoolWithType <T>(OBJ_POOL_TYPE type, string poolName, GameObject prefab, int minNum) where T : Component { ObjectPoolObj obj = null; ObjectPool <T> objPool = null; if (!objPoolWithCompDict.TryGetValue(type, out obj)) { // if no pool for the type, create one objPool = new ObjectPool <T>(poolName, prefab, minNum, true, true); objPool.poolGameObj.transform.SetParent(transform); objPoolWithCompDict.Add(type, objPool.objPoolObj); } else { objPool = (ObjectPool <T>)obj.GetComponent <ObjectPoolObj>().objPool; } return(objPool); }