Esempio n. 1
0
		//o(1)
		private void AddObjectToPool(PoolObject po) {
			//add to pool
			po.gameObject.SetActive(false);
			availableObjStack.Push(po);
			po.isPooled = true;
            po.transform.SetParent(poolRoot, false);
		}
Esempio n. 2
0
 public void ReturnObjectToPool(PoolObject po)
 {
     if (this.poolName.Equals(po.poolName))
     {
         if (po.isPooled)
         {
             Debug.LogWarning(po.gameObject.name + " is already in pool. Why are you trying to return it again? Check usage.");
         }
         else
         {
             this.AddObjectToPool(po);
         }
     }
     else
     {
         Debug.LogError(string.Format("Trying to add object to incorrect pool {0} {1}", po.poolName, this.poolName));
     }
 }
Esempio n. 3
0
 //o(1)
 public void ReturnObjectToPool(PoolObject po)
 {
     if (poolName.Equals(po.poolName))
     {
         /* we could have used availableObjStack.Contains(po) to check if this object is in pool.
          * While that would have been more robust, it would have made this method O(n)
          */
         if (po.isPooled)
         {
         }
         else
         {
             AddObjectToPool(po);
         }
     }
     else
     {
     }
 }
Esempio n. 4
0
        public void ReturnObjectToPool(GameObject go)
        {
            PoolObject po = go.GetComponent <PoolObject>();

            if (po == null)
            {
                Debug.LogWarning("Specified object is not a pooled instance: " + go.name);
            }
            else
            {
                if (poolDictionary.ContainsKey(po.poolName))
                {
                    Pool pool = poolDictionary[po.poolName];
                    pool.ReturnObjectToPool(po);
                }
                else
                {
                    Debug.LogWarning("No pool available with name: " + po.poolName);
                }
            }
        }
Esempio n. 5
0
 //o(1)
 public void ReturnObjectToPool(PoolObject po)
 {
     if (poolName.Equals(po.poolName))
     {
         /* we could have used availableObjStack.Contains(po) to check if this object is in pool.
          * While that would have been more robust, it would have made this method O(n)
          */
         if (po.isPooled)
         {
             Debug.LogWarning(po.gameObject.name + " is already in pool. Why are you trying to return it again? Check usage.");
         }
         else
         {
             AddObjectToPool(po);
         }
     }
     else
     {
         Debug.LogError(string.Format("Trying to add object to incorrect pool {0} {1}", po.poolName, poolName));
     }
 }
Esempio n. 6
0
		//o(1)
		public void ReturnObjectToPool(PoolObject po) {
			
			if(poolName.Equals(po.poolName)) {
				
				/* we could have used availableObjStack.Contains(po) to check if this object is in pool.
				 * While that would have been more robust, it would have made this method O(n) 
				 */
				if(po.isPooled) {
					Debug.LogWarning(po.gameObject.name + " is already in pool. Why are you trying to return it again? Check usage.");	
				} else {
					AddObjectToPool(po);
				}
				
			} else {
				Debug.LogError(string.Format("Trying to add object to incorrect pool {0} {1}",po.poolName,poolName));
			}
		}