Search Results for '전체 글'

389 POSTS

  1. 2020.10.13 ObjectPool

ObjectPool

Posted 2020. 10. 13. 16:24

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ObjectPool
{
    Queue<GameObject> q = new Queue<GameObject>();

public ObjectPool()
    {


    }
    public GameObject GetObject()
    {
        if (q.Count > 0)
        {
            GameObject g = q.Dequeue();
            g.SetActive(true);
            return g;
        }
        else
            return null;

    }
    public void SetObject(GameObject g)
    {
        g.SetActive(false);
        q.Enqueue(g);


    }

}

« PREV : 1 : ··· : 4 : 5 : 6 : 7 : 8 : 9 : 10 : ··· : 389 : NEXT »