ResourceManager.GetObjectFromPool C# (CSharp) 메소드

GetObjectFromPool() 공개 메소드

Returns an available object from the pool OR null in case the pool does not have any object available & can grow size is false.
public GetObjectFromPool ( string poolName, bool autoActive = true, int autoCreate ) : GameObject
poolName string
autoActive bool
autoCreate int
리턴 GameObject
    public GameObject GetObjectFromPool(string poolName, bool autoActive = true, int autoCreate = 0)
    {
        GameObject result = null;

        if (!poolDict.ContainsKey(poolName) && autoCreate > 0)
        {
            InitPool(poolName, autoCreate, PoolInflationType.INCREMENT);
        }

        if (poolDict.ContainsKey(poolName))
        {
            Pool pool = poolDict[poolName];
            result = pool.NextAvailableObject(autoActive);
            //scenario when no available object is found in pool
        #if UNITY_EDITOR
            if (result == null)
            {
                Debug.LogWarning("[ResourceManager]:No object available in " + poolName);
            }
        #endif
        }
        #if UNITY_EDITOR
        else
        {
            Debug.LogError("[ResourceManager]:Invalid pool name specified: " + poolName);
        }
        #endif
        return result;
    }