Exemplo n.º 1
0
        public object Spawn(Func <object> spawnFunc, string poolName, Action <object> onSpawnCallback = null)
        {
            if (!poolDict.TryGetValue(poolName, out var pool))
            {
                pool = new PoolCat(poolName, spawnFunc);
                poolDict[poolName] = pool;
            }

            var spawn = pool.Spawn(onSpawnCallback);

            return(spawn);
        }
Exemplo n.º 2
0
        public object Spawn(Type spawnType, string poolName = null, Action <object> onSpawnCallback = null)
        {
            poolName = poolName ?? spawnType.FullName;
            if (!poolDict.TryGetValue(poolName, out var pool))
            {
                pool = new PoolCat(poolName, spawnType);
                poolDict[poolName] = pool;
            }

            var spawn = pool.Spawn(onSpawnCallback);

            return(spawn);
        }
Exemplo n.º 3
0
        public static void Despawn(this GameObject self)
        {
            if (self == null)
            {
                return;
            }
            if (self.IsCacheContainsKey(PoolCatConst.Pool_Name))
            {
                PoolCat pool = self.GetCache <PoolCat>(PoolCatConst.Pool_Name);
                pool.Despawn(self);
            }

            //      else if (self.IsCacheContainsKey(PoolCatConst.Lua_Pool_Name))//Lua端调用
            //      {
            //        LuaTable pool = self.GetCache<LuaTable>(PoolCatConst.Lua_Pool_Name);
            //        pool.Get("Despawn", out LuaFunction despawnFunction);
            //        despawnFunction.Action(pool, self);
            //        despawnFunction.Dispose();
            //      }
        }
Exemplo n.º 4
0
 public static PoolCat AddPool(string poolName, PoolCat pool)
 {
     return(PoolCatManager.instance.AddPool(poolName, pool));
 }
Exemplo n.º 5
0
 public bool TryGetPool(string poolName, out PoolCat pool)
 {
     return(this.poolDict.TryGetValue(poolName, out pool));
 }
Exemplo n.º 6
0
 public PoolCat AddPool(string poolName, PoolCat pool)
 {
     poolDict[poolName] = pool;
     return(pool);
 }