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((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().color = new Color(1, 1, 1, 1f); } else { Training.transform.Find("Label").GetComponent().color = new Color(1, 1, 1, 0.5f); } TrainContent.gameObject.SetActive(isOn); }); Operation.onValueChanged.AddListener(isOn => { if (isOn) { Operation.transform.Find("Label").GetComponent().color = new Color(1, 1, 1, 1f); } else { Operation.transform.Find("Label").GetComponent().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 = "ûÓÐ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; StringEventSystem.Global.Send(this.GetType().Name + "Hide"); } protected override void OnClose() { } } }