Ejemplo n.º 1
0
        /// <summary>
        /// 回收对象池
        /// </summary>
        public void ReturnObject(PoolGameObject obj)
        {
            CreatePool();

            if (obj == null)
            {
                return;
            }

            if (!mPool.ContainsKey(obj.name))
            {
                mPool.Add(obj.name, new Queue <PoolGameObject>());
            }

            if (mPool[prefab.name].Count < Config.PoolCount)
            {
                mPool[prefab.name].Enqueue(temp);
            }
            else
            {
                Debug.LogWarning(prefab.name + "对象池已经超过" + Config.PoolCount + ",所以不再保存");
            }



            obj.Hide();
            obj.gameObjectStatus = GameObjectStaus.SLEEP;
            obj.SetParent(pool.transform);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 回收对象池
        /// </summary>
        public static void ReturnObject(PoolGameObject obj){
            Instance.CreatePool();

            if (obj==null) {
                return;
            }

            if (!Instance.mPool.ContainsKey(obj.name)){
                Instance.mPool.Add(obj.name, new Queue<PoolGameObject>());
            }
            Instance.mPool[obj.name].Enqueue(obj);
            obj.Hide();
            obj.gameObjectStatus = GameObjectStaus.SLEEP;
            obj.SetParent(Instance.pool.transform);
        }