2using System.Collections.Generic;
24 public void Create(
int _max,
int _addsPerUpdate = 10)
28 pools =
new Stack<T>(_max);
31 public T
Get(Component parent)
33 T obj = ((pools.Count > 0) ?
pools.Pop() :
Create());
34 Component obj2 = obj as Component;
35 obj2.transform.SetParent(parent.transform, worldPositionStays:
false);
36 obj2.SetActive(enable:
true);
44 Debug.LogError(
"tried to Get component");
71 (val as Component).SetActive(enable:
false);
92 return typeof(T).Name +
":" +
pools.Count;
98 public List<IItem>
items =
new List<IItem>();
113 public static Item<T> Create<T>(
int max = 100,
int addsPerUpdate = 10, Action<T> _onCreate =
null) where T : new()
116 item.Create(max, addsPerUpdate);
117 item.onCreate = _onCreate;
void Create(int _max, int _addsPerUpdate=10)
Item< T > SetMold(Component _mold)
override string ToString()
static Item< T > Create< T >(int max=100, int addsPerUpdate=10, Action< T > _onCreate=null)
static ObjectPool Instance