Example #1
0
 /// <summary>
 /// Recycles an object to the object pool
 /// </summary>
 /// <param name="InstanceId">Instance id of the object</param>
 public void Recycle(GameObject go)
 {
     if (!PooledObjects.Contains(go) && PooledObjects.Count < MaxItems)
     {
         IPooled ip = go.GetComponent <IPooled>();
         if (ip != null)
         {
             ip.OnRecycle();
         }
         go.SetActive(false);
         go.transform.position = Vector3.zero;
         PooledObjects.Push(go);
     }
 }