public void Hide(POOL_KEY key, GameObject obj) { usedPool[key].Pop(); freePool[key].Push(obj); obj.SetActive(false); obj.transform.parent = poolAnchor; }
public void Hide(POOL_KEY key) { var _freePool = freePool[key]; var _usedPool = usedPool[key]; while (_usedPool.Count > 0) { var obj = _usedPool.Pop(); obj.SetActive(false); obj.transform.parent = poolAnchor; _freePool.Push(obj); } }
// ======================================================================= public GameObject Show(POOL_KEY key, Vector3?wPos = null) { var _freePool = freePool[key]; var _usedPool = usedPool[key]; GameObject obj = null; if (_freePool.Count > 0) { obj = _freePool.Pop(); } else { obj = Instantiate(poolPrefabs[key], poolAnchor); } _usedPool.Push(obj); if (wPos != null) { obj.transform.position = wPos.Value; } obj.SetActive(true); return(obj); }