YanCheng_Metrology/Assets/Scripts/Project/UI/UI_Panel/UI_SelectModeOrDeviceTitleP...

100 lines
2.8 KiB
C#

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