Ejemplo n.º 1
0
        ///<summary>Manually return a PooledObject.</summary>
        public void ReturnedPooledObject(PooledObjSettings a_PooledObject, GameObject a_PoolOwner)
        {
            sPool pool = GetPoolStruct(a_PooledObject.gameObject);

            if (m_PoolsActiveObjects.ContainsKey(a_PooledObject.PoolOwner))
            {
                List <GameObject> activeObjects = m_PoolsActiveObjects[a_PoolOwner];

                if (activeObjects.Count != 0)
                {
                    activeObjects.Remove(a_PooledObject.gameObject);
                }
            }
        }
Ejemplo n.º 2
0
        ///<summary>Create a gameObject with the ask prefab for the PoolManager</summary>
        private void CreatePooledObject(GameObject aPoolPrefab)
        {
            GameObject        pooledObject = Instantiate(aPoolPrefab);
            PooledObjSettings pooledScript = pooledObject.AddComponent <PooledObjSettings>();

            if (pooledScript == null)
            {
                Debug.LogError(Debug_Error("Invalid Prefab for PoolManager"));
                Destroy(pooledObject);
            }
            else
            {
                pooledScript.InitPooledObject(aPoolPrefab);
                pooledObject.SetActive(false);

                m_PoolsInactiveObjects[aPoolPrefab].Add(pooledObject);
            }
        }