107 lines
3.1 KiB
C#
107 lines
3.1 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using QFramework;
|
|
using TMPro;
|
|
using System.Diagnostics.Eventing.Reader;
|
|
|
|
namespace QFramework.Example
|
|
{
|
|
public class UIInstructionData : UIPanelData
|
|
{
|
|
public bool isRightTop = false;
|
|
}
|
|
public partial class UIInstruction : UIPanel
|
|
{
|
|
bool isNo = false;
|
|
bool isOperation = false;
|
|
protected override void OnInit(IUIData uiData = null)
|
|
{
|
|
TypeEventSystem.Global.Register<OnModuleQuit>((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject);
|
|
mData = uiData as UIInstructionData ?? new UIInstructionData();
|
|
// please add init code here
|
|
Training.onValueChanged.AddListener(isOn =>
|
|
{
|
|
if (isOn)
|
|
{
|
|
Training.transform.Find("Label").GetComponent<TextMeshProUGUI>().color = new Color(0, 0, 0, 1f);
|
|
}
|
|
else
|
|
{
|
|
|
|
Training.transform.Find("Label").GetComponent<TextMeshProUGUI>().color = new Color(0, 0, 0, 0.5f);
|
|
}
|
|
TrainContent.gameObject.SetActive(isOn);
|
|
});
|
|
Operation.onValueChanged.AddListener(isOn =>
|
|
{
|
|
if (isOn)
|
|
{
|
|
Operation.transform.Find("Label").GetComponent<TextMeshProUGUI>().color = new Color(0, 0, 0, 1f);
|
|
}
|
|
else
|
|
{
|
|
|
|
Operation.transform.Find("Label").GetComponent<TextMeshProUGUI>().color = new Color(0, 0, 0, 0.5f);
|
|
}
|
|
OperationContent.gameObject.SetActive(isOn);
|
|
});
|
|
ConfirmBtn.onClick.AddListener(() =>
|
|
{
|
|
if (isOperation == false)
|
|
{
|
|
Operation.isOn = true;
|
|
isOperation = true;
|
|
}
|
|
else
|
|
{
|
|
Hide();
|
|
isNo = NoToggle.isOn;
|
|
|
|
}
|
|
});
|
|
|
|
|
|
}
|
|
|
|
protected override void OnOpen(IUIData uiData = null)
|
|
{
|
|
mData = uiData as UIInstructionData ?? new UIInstructionData();
|
|
|
|
if (string.IsNullOrEmpty(Global.Instance.curModule.Descript))
|
|
{
|
|
|
|
ContentText.text = "没有Descript相关配置";
|
|
}
|
|
else
|
|
{
|
|
ContentText.text = Global.Instance.curModule.Descript;
|
|
}
|
|
|
|
NoToggle.gameObject.SetActive(mData != null && mData.isRightTop == false);
|
|
|
|
}
|
|
|
|
protected override void OnShow()
|
|
{
|
|
if (isNo == true && mData != null && mData.isRightTop == false)
|
|
{
|
|
Hide();
|
|
}
|
|
}
|
|
|
|
protected override void OnHide()
|
|
{
|
|
mData = null;
|
|
// 防止后面紧接着的Action接收不到此消息 延迟0.1秒发送
|
|
ActionKit.Delay(0.1f, () =>
|
|
{
|
|
StringEventSystem.Global.Send(this.GetType().Name + "Hide");
|
|
}).StartGlobal();
|
|
}
|
|
|
|
protected override void OnClose()
|
|
{
|
|
}
|
|
}
|
|
}
|