The question and answer classes

The Question and Answer classes are very simple, and are used as data containers. Let's look at the Question.cs class first:

[System.Serializable]public class Question {     public string questionText;     public Answer[] answers;}
You may have noticed that the Question class does not derive from MonoBehaviour. It is a plain ol' vanilla C# class. As such, Unity will not serialize it by default, and it won't show up in the inspector. To let Unity know you want this class to be serialized, use the System.Serializable attribute at the top of the class definition.

As you can see, it's only a few lines of code. The first field, questionText, will be edited via the inspector in a later step. It is the display text for ...

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.