ObjectPool
using System.Collections; using System.Collections.Generic; using UnityEngine; public class ObjectPool { Queue q = new Queue(); 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); } }