using System; using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; //有样板代码 public class UI_SelectModeOrDeviceTitlePanel : BasePanel { /// /// 初始换 /// public void Init() { //获取用户数据显示头像 及用户名称 //更新倒计时 倒计时为全局变量 string mode = ""; switch (StudyOrPracticeMgr.Instance.ModeType) { case E_ModeType.None: GetControl("modelText (TMP)").gameObject.SetActive(false); break; case E_ModeType.Study: mode = "学习模式"; break; case E_ModeType.Practice: mode = "练习模式"; break; case E_ModeType.Exam: break; } GetControl("modelText (TMP)").text = mode; GetControl("modelText (TMP)").text = GameManager.DataMgr.userData.userName; } /// /// 显示 /// public override void ShowMe() { GameManager.EventMgr.AddEventListener(Enum_EventType.SwitchMode, SwitchMode); } /// /// 切换模式 /// private void SwitchMode() { string mode = ""; switch (StudyOrPracticeMgr.Instance.ModeType) { case E_ModeType.None: GetControl("modelText (TMP)").gameObject.SetActive(false); break; case E_ModeType.Study: mode = "学习模式"; break; case E_ModeType.Practice: mode = "练习模式"; break; case E_ModeType.Exam: break; } if (!GetControl("modelText (TMP)").gameObject.activeSelf) GetControl("modelText (TMP)").gameObject.SetActive(true); GetControl("modelText (TMP)").text = mode; } /// /// 隐藏 /// public override void HideMe() { GameManager.EventMgr.RemoveEventListener(Enum_EventType.SwitchMode, SwitchMode); } /// /// 按钮点击 /// /// protected override void OnClick(string btnName) { switch (btnName) { //TODO 退出提示框 case "Btn_Quit": print("退出应用"); GameManager.UIMgr.ShowPanel(E_UI_Layer.System, (panel) => { panel.Init("提示", "确定退出应用吗?", E_MessageType.Warning, () => { Application.Quit(); }); }); break; } } }