Creating a modular coin counter

This recipe teaches us how to use a Text (Script) and Image (Script) components along with a script to create a counter with an icon. It is similar to the counters in the two previous recipes, but, instead, to keep track of the score or lives, here we manage the number of coins possessed by the player. In contrast to the first counter that doesn't have an upper bound, or like the second counter that has a maximum for lives, here, when the player has reached a certain number of coins, something will happen. For example, a life will be added and the counter starts from zero, creating modularity.

How to do it...

  1. As for the first step of the previous recipe, we need to create a new UI text to show the number of lives. ...

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.