Creating a Collectibles UI Display with a Singleton UIManager

Here’s a quick guide to setting up a UI feedback element to report collectibles acquisition in your game.

Step 1: Tag your player as “Player” and your collectible as “Collectible”.

Step 2: In your player script create an int variable to track your collectibles as they are picked up:

Step 3: Create a collectibles script to handle destroying the game object when it is collected and apply it to your collectibles prefab:

Step 4: Create a new Text object and populate the text with the collectible you are tracking:

Step 5: Create a UIManager object and UIManager script. Implement the Singleton design pattern in the UIManager and add the UnityEngine.UI namespace:

Step 6: In the UIManager grab a handle to your text component and create a function to update the text while passing in the int value for # of collectibles acquired:

Step 7: Final step, in your player script track the incrementation of the collectibles acquired and pass it through to your UI manager by calling the relevant function and passing in the int value:

That’s it! Your collisions will now report out to your UIManager and update the collectibles count to your display.

Easy peasy! In the next guide I’ll cover setting up some moving platforms to add a challenge to our game. See ya there!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store