VirtualFramework/Assets/Scripts/UI/UIInstruction.cs

107 lines
3.1 KiB
C#
Raw Normal View History

2024-12-14 18:27:59 +08:00
using UnityEngine;
using UnityEngine.UI;
using QFramework;
using TMPro;
2025-01-09 17:08:20 +08:00
using System.Diagnostics.Eventing.Reader;
2024-12-14 18:27:59 +08:00
namespace QFramework.Example
{
public class UIInstructionData : UIPanelData
{
2025-02-27 18:35:44 +08:00
public bool isRightTop = false;
2024-12-14 18:27:59 +08:00
}
public partial class UIInstruction : UIPanel
{
2025-02-27 18:35:44 +08:00
bool isNo = false;
2025-02-28 18:28:19 +08:00
bool isOperation = false;
2024-12-14 18:27:59 +08:00
protected override void OnInit(IUIData uiData = null)
{
2025-01-09 09:43:15 +08:00
TypeEventSystem.Global.Register<OnModuleQuit>((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject);
2024-12-14 18:27:59 +08:00
mData = uiData as UIInstructionData ?? new UIInstructionData();
// please add init code here
Training.onValueChanged.AddListener(isOn =>
{
if (isOn)
{
2025-06-20 18:32:18 +08:00
Training.transform.Find("Label").GetComponent<TextMeshProUGUI>().color = new Color(0, 0, 0, 1f);
2024-12-14 18:27:59 +08:00
}
else
{
2025-06-20 18:32:18 +08:00
Training.transform.Find("Label").GetComponent<TextMeshProUGUI>().color = new Color(0, 0, 0, 0.5f);
2024-12-14 18:27:59 +08:00
}
TrainContent.gameObject.SetActive(isOn);
});
Operation.onValueChanged.AddListener(isOn =>
{
if (isOn)
{
2025-06-20 18:32:18 +08:00
Operation.transform.Find("Label").GetComponent<TextMeshProUGUI>().color = new Color(0, 0, 0, 1f);
2024-12-14 18:27:59 +08:00
}
else
{
2025-06-20 18:32:18 +08:00
Operation.transform.Find("Label").GetComponent<TextMeshProUGUI>().color = new Color(0, 0, 0, 0.5f);
2024-12-14 18:27:59 +08:00
}
OperationContent.gameObject.SetActive(isOn);
});
2025-02-27 18:35:44 +08:00
ConfirmBtn.onClick.AddListener(() =>
{
2025-02-28 18:28:19 +08:00
if (isOperation == false)
{
Operation.isOn = true;
isOperation = true;
}
else
{
Hide();
isNo = NoToggle.isOn;
}
2025-02-27 18:35:44 +08:00
});
2024-12-14 18:27:59 +08:00
}
protected override void OnOpen(IUIData uiData = null)
{
2025-02-27 18:35:44 +08:00
mData = uiData as UIInstructionData ?? new UIInstructionData();
2025-01-09 17:08:20 +08:00
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;
}
2025-02-27 18:35:44 +08:00
NoToggle.gameObject.SetActive(mData != null && mData.isRightTop == false);
2024-12-14 18:27:59 +08:00
}
protected override void OnShow()
{
2025-02-27 18:35:44 +08:00
if (isNo == true && mData != null && mData.isRightTop == false)
{
Hide();
}
2024-12-14 18:27:59 +08:00
}
protected override void OnHide()
{
2025-02-27 18:35:44 +08:00
mData = null;
2025-03-14 17:10:45 +08:00
// <20><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD>Action<6F><6E><EFBFBD>ղ<EFBFBD><D5B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ <20>ӳ<EFBFBD>0.1<EFBFBD><EFBFBD><EFBFBD>
ActionKit.Delay(0.1f, () =>
{
StringEventSystem.Global.Send(this.GetType().Name + "Hide");
}).StartGlobal();
2024-12-14 18:27:59 +08:00
}
protected override void OnClose()
{
}
}
}