コード例 #1
0
        public QGOPool CreatePool(string poolName, int initSize, int maxSize, GameObject prefab)
        {
            var pool = new QGOPool(poolName, prefab, initSize, maxSize, PoolRootObject);

            m_GameObjectPools[poolName] = pool;
            return(pool);
        }
コード例 #2
0
 public void Release(string poolName, GameObject go)
 {
     if (m_GameObjectPools.ContainsKey(poolName))
     {
         QGOPool pool = m_GameObjectPools[poolName];
         pool.ReturnObjectToPool(poolName, go);
     }
     else
     {
         Debug.LogWarning("No pool available with name: " + poolName);
     }
 }
コード例 #3
0
        public GameObject Get(string poolName)
        {
            GameObject result = null;

            if (m_GameObjectPools.ContainsKey(poolName))
            {
                QGOPool pool = m_GameObjectPools[poolName];
                result = pool.NextAvailableObject();
                if (result == null)
                {
                    Debug.LogWarning("No object available in pool. Consider setting fixedSize to false.: " + poolName);
                }
            }
            else
            {
                Debug.LogError("Invalid pool name specified: " + poolName);
            }
            return(result);
        }