I don’t know if we will add this to the game on the remaining lectures but I believe we wont.
I really want to make it that once an answer has been selected, or the time to answer has run out and the game is showing the correct answer, we have the option to go to the next question whenever we want and not having to wait the 30 seconds.
For this it occurs to me that it should be simple to add a new button called for example “NextQuestionButton”, and make it only active and visible during SetButtonState(false), and once the NextQuestion is loaded, this NextQuestionButton is inactive and invisible again.
I thought this could be simply done by creating the button object inside the QuizCanvas, creating a new serialized GameObject inside the script and asigning the NextQuestionButton to it. Then on the NextQuestionButton OnClick, put the QuizCanvas and attach a new Method that makes it go to the NextQuestion and disactivate itself.
Howver I simply can’t get to make the newQuestionButton to be set active or inactive, it says that the Game Object nextQuestionButton has no definitioin for SetActive():
[Header (“Next Question”)]
[SerializeField] GameObject nextQuestionButton;
void Start()
{
timer = FindObjectOfType();
scoreKeeper = FindObjectOfType();
scoreText.text = "Score: " + scoreKeeper.GetQuestionCount() + “/” +
scoreKeeper.GetQuestionCount() + " " + “0%”;
nextQuestionButton.SetActive(false); → Here is the problem
}
public void OnAnswerSelected (int index)
{
hasAnsweredEarly = true;
DisplayAnswer(index);
SetButtonState(false);
timer.CancelTimer();
scoreText.text = "Score: " + correctAnswerCount + “/” + scoreKeeper.GetQuestionCount() + " " +
scoreKeeper.CalculateScore() + “%”;
nextQuestionButton.SetActive(true); → here is the problem.
}
public void OnNextQuestionButtonSelected()
{
GetNextQuestion();
timer.CancelTimer();
nextQuestionButton.SetActive(false); —> Here is the problem
}
What am I missing, why can’t the new Button not be set as Active/Inactive?