コード例 #1
0
        public static bool AddEntry(string key, GameObject prefab, int prepopulate, int maxCount)
        {
            if (pools.ContainsKey(key))
            {
                return(false);
            }

            PoolData data = new PoolData();

            data.prefab   = prefab;
            data.maxCount = maxCount;
            data.pool     = new Queue <Poolable>(prepopulate);
            pools.Add(key, data);

            for (int i = 0; i < prepopulate; ++i)
            {
                Enqueue(CreateInstance(key, prefab));
            }

            return(true);
        }