void Update() { if (Time.time > _time) { PrefabPoolItem item = GetComponent <PrefabPoolItem>(); if (item != null) { item.Release(); } } }
public GameObject Get() { if (pool.Count > 0) { return(pool.Pop()); } else { GameObject go = Factory(); if (group != null) { go.transform.SetParent(group); } PrefabPoolItem t = go.GetComponent <PrefabPoolItem>(); if (t == null) { t = go.AddComponent <PrefabPoolItem>(); } t.Pool = this; return(go); } }