Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
 public MemoryPoolBase <TValue> WithExpandMethod(PoolExpandMethod expandMethod)
 {
     this.expandMethod = expandMethod;
     return(this);
 }