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); } }