Example #1
0
        /// <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;
            }
        }
Example #2
0
 /// <summary>
 ///  显示一个 element  并且把他 作为自己的子物体
 /// </summary>
 /// <param name="e"></param>
 public void SetChild(BaseElement child)
 {
     child.transform.SetParent(transform, false);
 }
Example #3
0
        /// <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);
        }
Example #4
0
 public void SetParent(BaseElement g)
 {
     parent = g;
     transform.SetParent(g.transform, false);
 }
Example #5
0
        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);
        }