예제 #1
0
    private GameObject CreatePoolObject()
    {
        RuntimePoolObject newItem = GameObject.Instantiate(prefab);

        newItem.SetPool(this);
        return(newItem.gameObject);
    }
예제 #2
0
    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();
    }