public static T CreatePoolEntity <T>(GameObject go) where T : PoolEntity { PoolEntity pool = null; poolList.TryGetValue(go.name, out pool); if (pool == null) { pool = go.AddComponent <T>(); poolList.Add(go.name, pool); } return(pool as T); }
public static void DestroyPool(string poolName) { PoolEntity singleton = null; poolList.TryGetValue(poolName, out singleton); if (singleton != null) { poolList.Remove(poolName); if (singleton) { GameObject.DestroyImmediate(singleton.gameObject); } } }
public static T CreatePoolEntity <T>(string name, Transform parent = null) where T : PoolEntity { PoolEntity pool = null; poolList.TryGetValue(name, out pool); if (pool == null) { GameObject newGo = new GameObject(name); if (parent) { newGo.transform.SetParent(parent); } pool = newGo.AddComponent <T>(); poolList.Add(name, pool); } return(pool as T); }
public void SetPool(PoolEntity pool) { this.pool = pool; }