I was getting a null exception query that was sending me to my DisplayQuestion() method and in particular the line highlighted:
void DisplayQuestion()
{
questionText.text = currentQuestion.GetQuestion(); // error pointed here
for (int i = 0; i < answerButtons.Length; i++)
{
TextMeshProUGUI buttonText = answerButtons[i].GetComponentInChildren<TextMeshProUGUI>();
buttonText.text = currentQuestion.GetAnswer(i);
}
}
On another thread here Alerazius posted a fix whereby one posts
currentQuestion = ScriptableObject.CreateInstance<QuestionSO>();
into the Start() method. For me, this solved the problem. But I do not understand why.
Could someone please explain why, in this particular context, this is necessary?
Thanks,
K