47 lines
1.0 KiB
C#
47 lines
1.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class A10GAnswerButton : MonoBehaviour
|
|
{
|
|
private A10GAnswerClass thisAnswer;
|
|
private Button thisBtn;
|
|
private Text thisTxt;
|
|
|
|
private void Awake()
|
|
{
|
|
thisTxt = GetComponentInChildren<Text>();
|
|
thisBtn = GetComponent<Button>();
|
|
thisBtn.onClick.AddListener(TestAnswer);
|
|
}
|
|
|
|
public void SetupThis(A10GAnswerClass rAnswer)
|
|
{
|
|
if (!thisBtn)
|
|
{
|
|
thisBtn = GetComponent<Button>();
|
|
}
|
|
thisBtn.interactable = true;
|
|
thisAnswer = rAnswer;
|
|
if (!thisTxt)
|
|
{
|
|
thisTxt = GetComponentInChildren<Text>();
|
|
}
|
|
thisTxt.text = thisAnswer.answer;
|
|
}
|
|
|
|
public void TestAnswer()
|
|
{
|
|
thisBtn.interactable = false;
|
|
if (thisAnswer.isCorrect)
|
|
{
|
|
A10GQuestionManager.instance.CorrectAnswer();
|
|
}
|
|
else
|
|
{
|
|
A10GQuestionManager.instance.WrongAnswer();
|
|
}
|
|
}
|
|
}
|