70 lines
1.9 KiB
C#
70 lines
1.9 KiB
C#
using System;
|
|
using Mono.Event;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace UnityTest.ZXL
|
|
{
|
|
public class ChoiceQuestionUI : UI
|
|
{
|
|
public Button btnFirst;
|
|
public Button btnSecond;
|
|
|
|
public Image imgFirst;
|
|
public Image imgSecond;
|
|
|
|
public Sprite yes_Garden;
|
|
public Sprite no_Garden;
|
|
|
|
public Sprite yes_Text;
|
|
public Sprite no_Text;
|
|
|
|
public override void OnInit()
|
|
{
|
|
base.OnInit();
|
|
btnFirst.onClick.AddListener(ClickFirst);
|
|
btnSecond.onClick.AddListener(ClickSecond);
|
|
}
|
|
|
|
public void SetIndex(int index)
|
|
{
|
|
if (index == 0)
|
|
{
|
|
btnFirst.enabled = true;
|
|
btnSecond.enabled = false;
|
|
|
|
btnFirst.GetComponent<Animator>().enabled = true;
|
|
btnSecond.GetComponent<Animator>().enabled = false;
|
|
|
|
btnFirst.image.sprite = yes_Garden;
|
|
imgFirst.sprite = yes_Text;
|
|
btnSecond.image.sprite = no_Garden;
|
|
imgSecond.sprite = no_Text;
|
|
}
|
|
else if (index == 1)
|
|
{
|
|
btnFirst.enabled = false;
|
|
btnSecond.enabled = true;
|
|
|
|
btnFirst.GetComponent<Animator>().enabled = false;
|
|
btnSecond.GetComponent<Animator>().enabled = true;
|
|
|
|
btnFirst.image.sprite = no_Garden;
|
|
imgFirst.sprite = no_Text;
|
|
btnSecond.image.sprite = yes_Garden;
|
|
imgSecond.sprite = yes_Text;
|
|
}
|
|
}
|
|
|
|
private void ClickFirst()
|
|
{
|
|
EventManager.Instance.FireNow(this, new ChoiceQuestionEventArgs(true));
|
|
}
|
|
|
|
private void ClickSecond()
|
|
{
|
|
EventManager.Instance.FireNow(this, new ChoiceQuestionEventArgs(false));
|
|
}
|
|
}
|
|
} |