void FillPool(PoolInfo info) { for (int i = 0; i < info.amount; i++) { GameObject obInstance = null; obInstance = Instantiate(info.prefab, info.container.transform); obInstance.gameObject.SetActive(false); obInstance.transform.position = defaultPos; info.pool.Add(obInstance); } }
public void CollObject(GameObject ob, PoolObjectType type) { ob.SetActive(false); ob.transform.position = defaultPos; PoolInfo selected = GetPoolByType(type); List <GameObject> pool = selected.pool; if (!pool.Contains(ob)) { pool.Add(ob); } }
public GameObject GetPoolObject(PoolObjectType type) { PoolInfo selected = GetPoolByType(type); List <GameObject> pool = selected.pool; GameObject obInstance = null; if (pool.Count > 0) { obInstance = pool[pool.Count - 1]; pool.Remove(obInstance); } else { obInstance = Instantiate(selected.prefab, selected.container.transform); } return(obInstance); }