Implementing a score counter
In this recipe, we are going to create a score counter that displays the score as a number on the screen. To achieve this, we will use the Text (Script) component and create a script to handle it. Different functions will be available from this script, that will be called from other scripts to increase the score.
How to do it...
- First of all, we need to create new UI text to display our score. Thus, right-click on the Hierarchy panel and then UI | Text. Finally, rename it to ScoreCounter.
To rename an object, right-click on it and select Rename. Otherwise, we can change its name in the Inspector window.
- Next, we can change the Font and the Font Size in the Inspector as we wish, to better suit our needs.
- Furthermore, ...
Get Unity UI Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.