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 OD_Answer_Btn : MonoBehaviour
|
|
{
|
|
private Button thisBtn;
|
|
private Text btnText;
|
|
private OD_Answer_Class thisClass;
|
|
private void Awake()
|
|
{
|
|
if (!thisBtn)
|
|
{
|
|
thisBtn = GetComponent<Button>();
|
|
thisBtn.onClick.AddListener(Answer);
|
|
}
|
|
btnText = GetComponentInChildren<Text>();
|
|
}
|
|
|
|
public void Answer()
|
|
{
|
|
if (thisClass.isCorrect)
|
|
{
|
|
OD_Question_Manager.instance.CorrectAnswer();
|
|
}
|
|
thisBtn.interactable = false;
|
|
}
|
|
|
|
public void Setup(OD_Answer_Class ans)
|
|
{
|
|
thisClass = ans;
|
|
if (!btnText)
|
|
{
|
|
btnText = GetComponentInChildren<Text>();
|
|
}
|
|
if (!thisBtn)
|
|
{
|
|
thisBtn = GetComponent<Button>();
|
|
thisBtn.onClick.AddListener(Answer);
|
|
}
|
|
btnText.text = thisClass.answerTxt;
|
|
thisBtn.interactable = true;
|
|
}
|
|
|
|
}
|