private GameObject CreatePoolObject() { RuntimePoolObject newItem = GameObject.Instantiate(prefab); newItem.SetPool(this); return(newItem.gameObject); }
public void Recycle(RuntimePoolObject item) { if (stack.Count > maxPoolObjects) { GameObject.Destroy(item.gameObject); return; } item.gameObject.SetActive(false); stack.Push(item); }
public override void DestroyItem(GameObject item) { RuntimePoolObject poolObject = item.GetComponent <RuntimePoolObject>(); if (poolObject == null) { Destroy(item); return; } poolObject.Recycle(); }