Displaying a digital clock
Whether it is real-world time or an in-game countdown clock, many games are enhanced by some form of clock or timer display. The following screenshot shows the kind of clock we will be creating in this recipe:
Figure 1.8: Displaying a digital clock when the scene is run
The most straightforward type of clock to display is a string composed of integers for hours, minutes, and seconds, which is what we’ll create in this recipe.
Getting ready
For this recipe, we have prepared the font that you will need in a folder named Fonts
in the 01_01
folder. If you have not done so already, create a Xolonium-Bold SDF
Font Asset file for the imported fonts, as described in the first recipe of this chapter.
How to do it…
To create a digital clock, follow these steps:
- Create a new Unity 2D project.
- Import the provided
Fonts
folder, containing yourXolonium-Bold SDF
Font Asset file. - Add a Text TMP GameObject...