Creating a symbolic lives counter
This recipe teaches us how to use multiple Image (Script) components inside a script in order to create a symbolic lives counter. The number of lives are not displayed as a number, but with heart symbols on the screen. It is similar to the counter in the Implementing a lives counter recipe, but the logic to manage different icons is different.
How to do it...
- To begin, let's create a new empty game object. To do this, right-click on the Canvas object, since we want it as parent, and then Create Empty. Finally, rename it as SymbolicLivesCounter.
If there isn't the Canvas object in the scene, for example, in new scenes, we can create it by right-clicking on Hierarchy panel and then go to UI | Canvas.
- Next, click ...
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.