List <GameObject> getpool(pooltype type) //get pool for a specific item { List <GameObject> ls; objects.TryGetValue(type, out ls); return(ls); }
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); }
public Poolpref(pooltype t, GameObject p, int n) { type = t; prefab = p; num = n; }