O'Reilly logo

Learning C# by Developing Games with Unity 3D Beginner's Guide by Terry Norton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required