The player will earn money by killing enemies, and he is able to spend it by buying new towers to defend his fortress. By doing this, we need a game element that is able to handle a money system, in which the amount of money can increase and decrease according to the player's actions. This section will teach us how to create a money system and integrate it in the UI.
As we previously did in the Lives Counter, we need to create the UI structure. So, let's create a new UI Image by right-clicking on the Hierarchy panel and then UI/Image. Rename it MoneyCounter
and assign to the Source Image the currency_square
image of our package. Also, we should press the Set Native Size button and then scale it down. As before, make it a tiny bit transparent by setting the alpha channel of the color variable to 232
. Finally, place it just under the LivesCounter
, as in the following image:
Similarly to the LivesCounter
, let's create a uiText...