42 lines
945 B
C#
42 lines
945 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class A1M2AnswerButton : MonoBehaviour
|
|
{
|
|
private Button thisBtn;
|
|
private Text thisTxt;
|
|
private A1M2AnswerClass thisAnswer;
|
|
|
|
public void SetupThis(A1M2AnswerClass answer)
|
|
{
|
|
thisAnswer = answer;
|
|
if (!thisBtn)
|
|
{
|
|
thisBtn = GetComponent<Button>();
|
|
thisBtn.onClick.AddListener(TestAnswer);
|
|
|
|
}
|
|
if (!thisTxt)
|
|
{
|
|
thisTxt = GetComponentInChildren<Text>();
|
|
}
|
|
thisBtn.interactable = true;
|
|
thisTxt.text = thisAnswer.answerString;
|
|
}
|
|
|
|
public void TestAnswer()
|
|
{
|
|
if (thisAnswer.isCorrect)
|
|
{
|
|
A1M2QuestionManager.instance.CorrectAnswer();
|
|
}
|
|
else
|
|
{
|
|
A1M2QuestionManager.instance.WrongAnswer();
|
|
}
|
|
thisBtn.interactable = false;
|
|
}
|
|
}
|