/// <summary> /// 出池子 /// </summary> /// <returns></returns> public GameObject Spawn() { GameObject obj = null; foreach (GameObject item in subList) { if (!item.activeSelf) { obj = item; break; } } if (obj == null) { obj = GameObject.Instantiate(m_Prefab); subList.Add(obj); } obj.SetActive(true); IResuable ir = obj.GetComponent <IResuable>(); if (ir != null) { ir.Spawn(); } return(obj); }
/// <summary> /// 入池子 /// </summary> /// <param name="obj"></param> public void UnSpawn(GameObject obj) { if (subList.Contains(obj)) { IResuable ir = obj.GetComponent <IResuable>(); if (ir != null) { ir.UnSpawn(); } obj.SetActive(false); } }