using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; //有样板代码 public class UI_SelectModeOrDeviceTitlePanel : BasePanel { /// /// 初始换 /// public void Init() { //获取用户数据显示头像 及用户名称 //更新倒计时 倒计时为全局变量 string mode = ""; switch (StudyOrPracticeMgr.Instance.ModeType) { case E_ModeType.None: GetControl("Text_ModeType").gameObject.SetActive(false); break; case E_ModeType.Study: mode = "学习模式"; break; case E_ModeType.Practice: mode = "练习模式"; break; case E_ModeType.Exam: break; } GetControl("Text_ModeType").text = mode; GetControl("Text_UserName").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("Text_ModeType").gameObject.SetActive(false); break; case E_ModeType.Study: mode = "学习模式"; break; case E_ModeType.Practice: mode = "练习模式"; break; case E_ModeType.Exam: break; } if (!GetControl("Text_ModeType").gameObject.activeSelf) GetControl("Text_ModeType").gameObject.SetActive(true); GetControl("Text_ModeType").text = mode; } /// /// 隐藏 /// public override void HideMe() { GameManager.EventMgr.RemoveEventListener(Enum_EventType.SwitchMode, SwitchMode); } /// /// 按钮点击 /// /// protected override void OnClick(string btnName) { base.OnClick(btnName); switch (btnName) { //TODO 退出提示框 case "Btn_Quit": print("退出应用"); break; } } }