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); }
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); }
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(); // } }
public static PoolCat AddPool(string poolName, PoolCat pool) { return(PoolCatManager.instance.AddPool(poolName, pool)); }
public bool TryGetPool(string poolName, out PoolCat pool) { return(this.poolDict.TryGetValue(poolName, out pool)); }
public PoolCat AddPool(string poolName, PoolCat pool) { poolDict[poolName] = pool; return(pool); }