For Exercise 2 and 3, we’ll use the Scene from Exercise 1.
Rename ChangeText to ClockDisplay.
Create a new C# script called Clock and attach it to ClockDisplay.
Double click Clock to open in Visual Studio.
Beginning on line 4, type:
Select Canvas in the Hierarchy and, from the GameObject dropdown, select Create Empty Child. Name this ButtonGridHolder. Drag it above ClockDisplay in the Hierarchy so that ClockDisplay is rendered over ButtonGridHolder’s child elements. (Figure 03)
Add a Grid Layout Group component to ButtonGridHolder.
From the GameObject dropdown, select UI > Button.
Drag the Button onto ButtonGridHolder to put it under the control of the Grid Layout Group. (Figure 05)
Highlight the Button and hold Ctrl-D (or Command-D on a Mac) until Buttons fill the screen.
From the GameObject dropdown, select UI > Image. Name it MovingImage.
Create a new C# script called ImageMover and attach it to MovingImage.
Double click ImageMover to open it in Visual Studio.
Beginning on line 6, type:
Click the Image in the Hierarchy to select it, and drop Canvas in the slot marked Base Rect Transform. This will anchor our Image to the center of the canvas.
Press Play, and monitor the Profiler.
Exit Play Mode.