LaboratoryProtection/Assets/UnityTest/ZXL/Scripts/UI/ChoiceQuestionUI.cs

44 lines
1.0 KiB
C#
Raw Normal View History

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);
}
2023-10-05 02:31:29 +08:00
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));
}
}
}