Loading up the questions

We provide a simple method named LoadQuestion to pull the values from our data classes into the UI and display them to the player. The code looks like this:

private void LoadQuestion(int index) {    if (index < questions.Length)     {        questionText.text = questions[index].questionText;        firstAnswerButton.GetComponentInChildren<Text>().text = questions[index].answers[0].answerText;        secondAnswerButton.GetComponentInChildren<Text>().text = questions[index].answers[1].answerText;        thirdAnswerButton.GetComponentInChildren<Text>().text = questions[index].answers[2].answerText;    }     else     {        EndConversation();    }}

The LoadQuestion method takes in a question index, which corresponds to the index of the question in the array questions[] ...

Get Unity 2017 Game AI Programming - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.