UnityPooler.PoolableGameObject.ReuseObject C# (CSharp) Method

ReuseObject() private method

private ReuseObject ( ) : PoolableGameObject
return PoolableGameObject
        private PoolableGameObject ReuseObject()
        {
            // Find an active object
            PoolableGameObject objToUse;
            LinkedListNode<PoolableGameObject> objNode;

            do
            {
                if (_liveObjs.Count == 0)
                {
                    // We couldn't find an object...this is pretty unexpected (capAmount maybe set to 0)
                    return null;
                }

                objNode = _liveObjs.First;
                _liveObjs.RemoveFirst();
                objToUse = objNode.Value;
            }
            while (objToUse == null || objToUse.gameObject == null || !objToUse._isActive);

            for (int i = 0; i < _poolables.Length; i++)
            {
                _poolables[i].OnObjectReused();
            }

            _liveObjs.AddLast(objNode);

            return objToUse;
        }