123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class UIBase : MonoBehaviour
- {
- public SimpleUIdata UIData;
- public System.Object UICanshu;
- public virtual bool NeedBroad { get; }
- protected virtual void Awake()
- {
-
- }
- protected virtual void Start()
- {
- MessageCenterController.Instance.Register(GameEnum.MESSAGE_TONGBU_UI_CHANGE, TongbuData);
- }
- protected virtual void OnDestroy()
- {
- MessageCenterController.Instance.UnRegister(GameEnum.MESSAGE_TONGBU_UI_CHANGE, TongbuData);
- }
- protected virtual void LateUpdate()
- {
- //UIData.Pos = this.gameObject.transform.position;
- //UIData.Eurl = this.gameObject.transform.eulerAngles;
- }
- public virtual void InitSimpleUIdata()
- {
- }
- protected virtual void Refresh()
- {
- }
- private void TongbuData(System.Object datas)
- {
- if(UIData == null)
- {
- return;
- }
- SimpleUIdata checkData = datas as SimpleUIdata;
- if (checkData.GetUIKey().Equals(UIData.GetUIKey()))
- {
- UICanshu = UIDataManager.Instance.GetDataByKeyId(UIData.GetUIKey());
- Refresh();
- }
- }
- protected void ShowDataRefresh()
- {
- //防止 UIData 是空的
- if (UIData == null)
- {
- InitSimpleUIdata();
- }
- UICanshu =UIDataManager.Instance.GetDataByKeyId(UIData.GetUIKey());
- }
- protected virtual void HideDataSend()
- {
- if (NeedBroad)
- UIDataManager.Instance.RefreshUI(UIData, UICanshu,UIDataMode.Del);
- }
- protected virtual void ShowDataSend()
- {
- if(NeedBroad)
- UIDataManager.Instance.RefreshUI(UIData, UICanshu, UIDataMode.Add);
- }
- protected virtual void RefreshDataSend()
- {
- if(NeedBroad)
- UIDataManager.Instance.RefreshUI(UIData, UICanshu, UIDataMode.Refresh);
- }
- }
|