VirtualFramework/Assets/Scripts/UI/UIInstruction.cs
2025-02-28 18:28:19 +08:00

102 lines
2.9 KiB
C#
Raw Blame History

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(1, 1, 1, 1f);
}
else
{
Training.transform.Find("Label").GetComponent<TextMeshProUGUI>().color = new Color(1, 1, 1, 0.5f);
}
TrainContent.gameObject.SetActive(isOn);
});
Operation.onValueChanged.AddListener(isOn =>
{
if (isOn)
{
Operation.transform.Find("Label").GetComponent<TextMeshProUGUI>().color = new Color(1, 1, 1, 1f);
}
else
{
Operation.transform.Find("Label").GetComponent<TextMeshProUGUI>().color = new Color(1, 1, 1, 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 = <><C3BB>Descript<70><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
}
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;
}
protected override void OnClose()
{
}
}
}