예제 #1
0
        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);
        }
예제 #2
0
        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);
                }
            }
        }
예제 #3
0
        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);
        }
예제 #4
0
 public void SetPool(PoolEntity pool)
 {
     this.pool = pool;
 }