/// <summary> /// 销毁BaseElement 重载方法 /// </summary> public virtual void Destory() { if (compomentList != null) { for (int i = 0; i < compomentList.Count; i++) { compomentList[i].Destory(); } compomentList.Clear(); compomentList = null; } if (coroutineList != null) { for (int i = 0; i < coroutineList.Count; i++) { StopCoroutine(coroutineList[i]); } coroutineList.Clear(); coroutineList = null; } if (subElementDic != null) { if (subElementDic.Count != 0) { foreach (var item in subElementDic) { item.Value.Destory(); } } subElementDic.Clear(); subElementDic = null; } if (messageTypeDic != null) { foreach (var item in messageTypeDic) { NotificationCenter.Instance.RemoveObserver(this, item.Key); } messageTypeDic.Clear(); messageTypeDic = null; } parent = null; gameObject = null; if (IsNeedUpdate == true) { IsNeedUpdate = false; } if (IsNeedFixedUpdate == true) { IsNeedFixedUpdate = false; } if (IsNeedLateUpdate == true) { IsNeedLateUpdate = false; } }
/// <summary> /// 显示一个 element 并且把他 作为自己的子物体 /// </summary> /// <param name="e"></param> public void SetChild(BaseElement child) { child.transform.SetParent(transform, false); }
/// <summary> /// 添加子元素 方法 /// </summary> /// <param name="ele"></param> public void AddSubElement <T>(GameObject obj = null) where T : BaseElement, new() { T t1 = BaseElement.CreateElementWithGameObject <T>(obj); SubElementDic.Add(t1.elementID, t1); }
public void SetParent(BaseElement g) { parent = g; transform.SetParent(g.transform, false); }
public static T CreateElementWithGameObjectAndParent <T>(GameObject g = null, BaseElement parent = null) where T : BaseElement, new() { T t1 = new T(); t1.elementID = GetGlobalID(); t1.parent = parent; t1.SetGameObject(g); t1.Awake(); return(t1); }