public void AddNewPool <TValue>(GameObject prefab, int initialPoolSize = 1, PoolExpandMethod poolExpandMethod = PoolExpandMethod.ExpandByOne) where TValue : Component, IPoolable { string prefabID = GetPrefabID(prefab.gameObject); if (!memoryPools.ContainsKey(prefabID)) { IMemoryPool mp = new GameObjectMemoryPool <TValue>() .WithInitialPoolSize(initialPoolSize) .WithExpandMethod(poolExpandMethod) .FromFactory(new PrefabFactory <TValue>(prefab.gameObject)); memoryPools.Add(prefabID, mp); poolParents.Add(prefabID, new GameObject($"Pool - {prefabID}").transform); } }
public MemoryPoolBase <TValue> WithExpandMethod(PoolExpandMethod expandMethod) { this.expandMethod = expandMethod; return(this); }