Unity_Learn/Assets/Scripts/Managers/PoolManager.cs

44 lines
1.2 KiB
C#

using System.Collections.Generic;
using UnityEngine;
public class PoolManager
{
// Pool하는데 만약에 A 와 B가 있는데 이게 전부 다 같은 Pool_root 밑에 있으면
// A를 Push 했다가 B를 Pop 할 수도 있음
// 그래서 A와 B를 구분하기 위해서 Dictionary를 사용함
class Pool
{
public GameObject Original {get; private set;}
// A 나 B같은 오브젝트들이 뭉쳐질 위치
public Transform Root {get; private set;}
// 스택 큐 다상관 없는데
Stack<Poolable> _poolStack = new Stack<Poolable>();
}
Dictionary<string, Pool> _pool = new Dictionary<string, Pool>();
Transform _root;
public void Init()
{
if (_root == null)
{
_root = new GameObject { name = "@Pool_Root" }.transform;
Object.DontDestroyOnLoad(_root);
}
}
public void Push(Poolable poolable)
{
}
public Poolable Pop(GameObject original, Transform parent = null)
{
return null;
}
public GameObject GetOriginal(string path)
{
return Managers.Resource.Load<GameObject>($"Prefabs/{path}");
}
}