using System; using Mono.Event; using TMPro; using UnityEngine.UI; namespace UnityTest.ZXL { public class ChoiceQuestionUI : UI { public Button btnFirst; public Button btnSecond; public override void OnInit() { base.OnInit(); btnFirst.onClick.AddListener(ClickFirst); btnSecond.onClick.AddListener(ClickSecond); } public void SetIndex(int index) { if (index == 0) { btnFirst.interactable = true; btnSecond.interactable = false; } else if (index == 1) { btnFirst.interactable = false; btnSecond.interactable = true; } } private void ClickFirst() { EventManager.Instance.FireNow(this, new ChoiceQuestionEventArgs(true)); } private void ClickSecond() { EventManager.Instance.FireNow(this, new ChoiceQuestionEventArgs(false)); } } }