public void Destroy() { ObjectPoolRef r = this.GetComponent <ObjectPoolRef>(); if (r != null) { r.Pool.Unspawn(this.gameObject); } else { Destroy(this.gameObject); } }
void CreateObject() { Object o = GameObject.Instantiate(Obj); SetToParent(o); Available.Add(o); GameObject g = o as GameObject; if (g != null) { ObjectPoolRef r = g.GetComponent <ObjectPoolRef>(); if (r == null) { r = g.AddComponent <ObjectPoolRef>(); r.Pool = this; } } }