We are going to use a pattern called a Singleton in order to implement a class that we can access from anywhere in our code, much like the input class from Unity that is currently used. Unity has the benefit of making the input completely static, but for our purposes, we will use the well-defined scripting version. Open the editor and follow the next exercise to build the TestingInput script and object:
- Select the HoDLG | Scripts folder and open the Create menu.
- From the Create menu, select C# Script. Name the new script Singleton. This script is the standard pattern script from http://wiki.unity3d.com/index.php/Singleton; the script is shown as follows:
using UnityEngine;namespace Packt.HoDLG{ /// <summary> /// ...