Hi! I have a quiz game with 5 possible answers for which I have an array of 5 buttons. When one button is pressed, I want the button number to be checked against the answer number, so that either “correct” or “incorrect” comes up. How do I get the pressed button to return its integer? I tried using onClick listener but either it is the wrong thing to use or I am not doing it right… Any help would be appreciated.
This is what I have at the moment:
public void GetButtonPressed()
{
}
public void checkAnswer()
{
{
if (allowSelection)
{
if (buttonPressed == correctAnswerNum)
{
print("correct");
numberOfCorrectAnswers++;
feedbackText.GetComponent<Text>().text = "Correct!";
feedbackText.GetComponent<Text>().color = Color.white;
}
else
{
print("incorrect");
feedbackText.GetComponent<Text>().text = "Incorrect!";
feedbackText.GetComponent<Text>().color = Color.white;
}