Creating a HUD (part 2)

Toggling on and off the Key and Winged Boots icon on the HUD

Now that we have our HUD in place, it is time to make the two icons we designed in Illustrator to show up on the HUD once you buy the corresponding item.

HUD UI prep:

By default the two icons is going to be turned off. We previously had imported and slice the two icons already (if not, go ahead and complete that). Then we will insert them into the HUD UI panel.

Make sure both icons are turned off by default.

Merchant NPC script:

In the Merchant script, we are going to get two “Game Object” handles for the two icons.

Then in the “Buy Item” public method, we are going to individually insert these game objects and turn them on according to what the player has bought. We do this within the switch statement where we can call the icon handler and make that game object active.

Now back in Unity, when we try to buy an Key or boot item, we can see that the icon is turned on.

Turning off the Main HUD:

If you have noticed, when you have toggle the shop UI, the main HUD and touch controls (which we will create in a later article) are overlapping.

very ugly indeed.

To solve this, we will follow a similar method just like how we turned on the keys and boots icon, we can also turn off UI as well.

Currently within our Merchant script, we have our On Trigger Enter script controlling the shop UI pop up. Within the same method we can also turn off the main HUD by giving the HUD game object a handle within the Merchant script and setting it to be deactivated during the Shop UI is turned on.

The Hud UI is being set to deactivated

We then do the exact opposite when the player leaves the shop.

If you have noticed, I also added in a Fader Animator with the parameter of “Fade Out” when the Main HUD disappears and reappears. The fader is controlling the Touch UI (again which we will go into at a later article). But for now we can see what the results would look like.

A Designer, an Illustrator and a massive tech geek aspiring to become a professional Unity Developer.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Update RKHunter & Fix False Positives

How to create Windows service to schedule task with Topshelf and FluentScheduler- Part 2

Assignment Week 2

Video timelapse from rtsp/jpeg to mp4 on google drive

Executing Azure Databricks Notebook in Azure Data Factory Pipeline Using Access Tokens

How to Connect an Android Phone to a Docker Container ?

Using Django’s built in signals and writing custom signals.

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
Simon Truong

Simon Truong

A Designer, an Illustrator and a massive tech geek aspiring to become a professional Unity Developer.

More from Medium

Creating the Main Menu

Unity new Input System : Player Input Component (Part XII)

2.5D Platformer setup: Movement and Collectibles

Install Unity’s new input system