Time for action – creating a GameData script

We could create a regular C# class for this, but we want to be able to assign some values in Unity's Inspector, so we'll create a Unity C# Script instead. There are times when you will want to use the Inspector, and other times, when assigning values in code is better.

To start, we are going to create three variables to store the images used for the three splash screens in BeginState, WonStates, and LostStates.

Note

By now, you should know how to create a C# Script in Unity or in MonoDevelop. From now on, you should simply create the script using whichever is most convenient at the time.

  1. In the Scripts folder, create a new C# Script named GameData, containing the following code:
    using UnityEngine; using ...

Get Learning C# by Developing Games with Unity 3D Beginner's Guide 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.