Пример #1
0
 public T FetchFromPool()
 {
     if (PoolStack.Count > 0)
     {
         return(PoolStack.Pop());
     }
     else
     {
         return(CreatePooledObject());
     }
 }
Пример #2
0
 public PoolObject GetInstance()
 {
     if (stack.Count > 0)
     {
         var obj = stack.Pop();
         if (obj == null)
         {
             return(GetInstance());
         }
         obj.gameObject.SetActive(true);
         return(obj);
     }
     return(Instantiate(this));
 }