Пример #1
0
    List <GameObject> getpool(pooltype type)   //get pool for a specific item
    {
        List <GameObject> ls;

        objects.TryGetValue(type, out ls);
        return(ls);
    }
Пример #2
0
 public GameObject getobj(pooltype type)     //get instance of an object from pool
 {
     if (!(objects == null))
     {
         List <GameObject> ls = getpool(type);
         for (int i = 0; i < ls.Count; i++)
         {
             if (!ls [i].activeInHierarchy)
             {
                 return(ls [i]);
             }
         }
     }
     if (expand)
     {
         for (int i = 0; i < prefs.Count; i++)
         {
             if (prefs[i].type == type)
             {
                 GameObject obj = Instantiate(prefs [i].prefab, transform);
                 obj.SetActive(false);
                 getpool(type).Add(obj);
                 return(obj);
             }
         }
     }
     return(null);
 }
Пример #3
0
 public Poolpref(pooltype t, GameObject p, int n)
 {
     type   = t;
     prefab = p;
     num    = n;
 }