In this recipe, you added a Text GameObject to a scene. Then, you added an instance of the ClockDigital C# script class to that GameObject.
Notice that as well as the standard two C# packages (UnityEngine and System.Collections) that are written by default for every new script, you added the using statements to two more C# script packages, UnityEngine.UI and System. The UI package is needed since our code uses the UI text object, and the System package is needed since it contains the DateTime class that we need to access the clock on the computer where our game is running.
There is one variable, textClock, which will be a reference to the Text component, whose text content we wish to update in each frame with the current time in hours, minutes, and seconds.
The Awake() method (executed when the scene begins) sets the textClock variable to be a reference to the Text component in the GameObject, to which our scripted object has been added. Storing a reference to a component...