Exemplo n.º 1
0
        /// <summary>
        /// 销毁游戏对象
        /// </summary>
        /// <param name="key"></param>
        /// <param name="obj"></param>
        public static void Destroy(string key, GameObject obj)
        {
            BlockPool bPool = null;

            if (objPools.TryGetValue(key, out bPool))
            {
                bPool.Destroy(obj);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 初始化对象缓冲池
        /// </summary>
        /// <param name="key"></param>
        /// <param name="obj"></param>
        /// <param name="initialCapacity"></param>
        public static void InitPool(string key, GameObject obj, int initialCapacity = 10)
        {
            BlockPool bPool = null;

            if (!objPools.TryGetValue(key, out bPool))
            {
                bPool = new BlockPool(obj, initialCapacity);
                objPools.Add(key, bPool);
            }
        }
Exemplo n.º 3
0
        public static T GetObject <T>(string key, Vector3 pos) where T : Component
        {
            T         t     = null;
            BlockPool bPool = null;

            if (objPools.TryGetValue(key, out bPool))
            {
                t = bPool.GetObject <T>(pos);
            }
            if (t == null)
            {
                GameLog.Error(string.Format("{0} cache get err!", key));
            }
            return(t);
        }
Exemplo n.º 4
0
        public static GameObject GetObject(string key, Vector3 pos)
        {
            GameObject cacheGo = null;
            BlockPool  bPool   = null;

            if (objPools.TryGetValue(key, out bPool))
            {
                cacheGo = bPool.GetObject(pos);
            }
            if (cacheGo == null)
            {
                GameLog.Error(string.Format("{0} cache get err!", key));
            }
            return(cacheGo);
        }