void LoadUnit(int _num, OBJECT_POOL_KEY _key) { GameObject unit; for (int i = 0; i < _num; i++) { unit = UnitManager.GetInstance.PopPoolObject(_key); unit.SetActive(true); unit.transform.position = new Vector3(data.units[idx].pos[0], data.units[idx].pos[1], data.units[idx].pos[2]); idx++; } }
public GameObject PopPoolObject(OBJECT_POOL_KEY _key) { if (objectPoolManager[_key].Count <= 0) { return(null); } objectPoolManager[_key].Peek().transform.parent = null; objectPoolManager[_key].Peek().SetActive(true); objectPoolManager[_key].Peek().GetComponent <Unit>().WhenSpawn(); return(objectPoolManager[_key].Pop()); }
void Init_Pool(out Stack <GameObject> _stack, GameObject _prefab, int _count, OBJECT_POOL_KEY _key) { GameObject temp; _stack = new Stack <GameObject>(); objectPoolManager.Add(_key, _stack); for (int i = 0; i < _count; i++) { temp = Instantiate(_prefab); _stack.Push(temp); _stack.Peek().SetActive(false); _stack.Peek().transform.SetParent(this.gameObject.transform); } }
public void PushPoolObject(OBJECT_POOL_KEY _key, GameObject _obj) { objectPoolManager[_key].Push(_obj); _obj.transform.SetParent(this.gameObject.transform); }