예제 #1
0
        /// <summary>
        /// 创建对象
        /// </summary>
        /// <param name="name"> 对象名</param>
        /// <returns></returns>
        public GameObject Spawn(string name)
        {
            if (!f_pools.ContainsKey(name))
            {
                RegisterNewPool(name);
            }

            FBSubPool pool = f_pools[name];

            return(pool.Spawn());
        }
예제 #2
0
        /// <summary> 回收对象 </summary>
        public void Unspawn(GameObject go)
        {
            FBSubPool pool = null;

            foreach (FBSubPool p in f_pools.Values)
            {
                if (p.IsContains(go))
                {
                    pool = p;
                    break;
                }
            }

            pool.Unspawn(go);
        }
예제 #3
0
        /// <summary> 创建一个新的SubPool </summary>
        void RegisterNewPool(string name)
        {
            string path = "";

            if (string.IsNullOrEmpty(ResourceDir))
            {
                path = name;
            }
            else
            {
                path = ResourceDir + "/" + name;
            }

            GameObject prefab = Resources.Load <GameObject>(path);
            FBSubPool  pool   = new FBSubPool(transform, prefab);

            f_pools.Add(pool.Name, pool);
        }