Пример #1
0
        public static Pool GetPool(PooledMonoBehaviour pooledObject)
        {
            if (Pools.ContainsKey(pooledObject))
            {
                return(Pools[pooledObject]);
            }

            var pool = new GameObject($"Pool-{pooledObject.name}").AddComponent <Pool>();

            DontDestroyOnLoad(pool);
            pool.toPool = pooledObject;
            for (int i = 0; i < pooledObject.InitialPoolSize; i++)
            {
                pool.GrowPool();
            }

            Pools.Add(pooledObject, pool);
            return(pool);
        }
Пример #2
0
 private void AddObjectToQueue(PooledMonoBehaviour pooled)
 {
     _pooledObjects.Enqueue(pooled);
 }