So I’m following a tutorial on making a simple game and I am getting an error that is stopping my development.
Assets/TextManager.cs(35,22): error CS1061: Type UnityEngine.UI.Button.ButtonClickedEvent' does not contain a definition for
Addlistener’ and no extension method Addlistener' of type
UnityEngine.UI.Button.ButtonClickedEvent’ could be found. Are you missing an assembly reference?
Here is my code.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TextManager : MonoBehaviour {
public Text text;
public Button trueButton;
public Button falseButton;
public bool option1;
public bool option2;
private enum States
{
question, trueState, falseState,
};
private States myState;
void Start () {
myState = States.question;
}
void Update () {
if (myState == States.question) {question ();}
else if (myState == States.trueState) {trueState ();}
else if (myState == States.falseState) {falseState ();}
}
void onEnable () {
trueButton.onClick.Addlistener (delegate {option1 = true;});
falseButton.onClick.Addlistener (delegate {option2 = true;});
}
void question () {
text.text = “Ice is cold.”;
if (option1 == true) {
myState = States.trueState;
} else if (option2 == true) {
myState = States.falseState;}
}
void trueState () {
text.text = “Correct”;
}
void falseState (){
text.text = “WRONG!!!”;
}
}