Example #1
0
 /// <summary>
 /// Returns all currently allocated prefabs to the pool.
 /// </summary>
 public void Reset()
 {
     if (m_InnerPool != null && m_ActiveObjects.Count > 0)
     {
         using (PooledList <T> tempList = PooledList <T> .Create(m_ActiveObjects))
         {
             m_InnerPool.Free(tempList);
         }
     }
 }
Example #2
0
        private void OnFreeCheckComponents(IPool <T> inPool, T inElement)
        {
            using (PooledList <IPoolAllocHandler> children = PooledList <IPoolAllocHandler> .Create())
            {
                inElement.GetComponentsInChildren <IPoolAllocHandler>(true, children);

                for (int i = 0, length = children.Count; i < length; ++i)
                {
                    if (!m_ComponentSkipSelfAlloc || children[i] != inElement)
                    {
                        children[i].OnFree();
                    }
                }
            }
        }
Example #3
0
        /// <summary>
        /// Frees all allocated prefabs currently in the given scene.
        /// </summary>
        public int FreeAllInScene(Scene inScene)
        {
            if (m_InnerPool != null)
            {
                using (PooledList <T> tempList = PooledList <T> .Create())
                {
                    foreach (var activeObj in m_ActiveObjects)
                    {
                        if (activeObj.gameObject.scene == inScene)
                        {
                            tempList.Add(activeObj);
                        }
                    }

                    int finalCount = tempList.Count;
                    m_InnerPool.Free(tempList);
                    return(finalCount);
                }
            }

            return(0);
        }