Displaying multiple pickups of the same object with text totals

When several items of the same type have been picked up, often the simplest way to convey what is being carried to the user is to display a text message showing the numeric total of each item type being carried, as shown in the following screenshot. In this recipe, the total number of stars collected is displayed using a UI Text object.

Displaying multiple pickups of the same object with text totals

Getting ready

This recipe assumes you are starting with project Simple2Dgame_SpaceGirl setup from the first recipe in this chapter. The font you need can be found in folder 1362_02_02.

How to do it...

To display inventory total text for multiple pickups ...

Get Unity 5.x 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.