A UI for everyone, Unity makes it easy!

Edward Kim
3 min readApr 8, 2021

--

So this is where we are at, but it is still missing something…

A UI! We are missing a UI! A HUD and also Menu is crucial for most games to have for communicating with the Player.

Luckily, Unity makes it easy to create a basic UI and well that is good for me.

So what is it that I need first. Lets make the HUD.

Using a empty object, I created a UI Manager in my main game scene which houses all the important UI Elements. Just like simple 3d shapes, you just right click and create whichever UI elements you need. Images, text, buttons, it is all there!

Then with some proper placement, we have ourselves a simple HUD.

Using a separate script for the UI Manager, and some script communication, I was able to get a working score keeper, and a lives display based on communication from the Player script.

All the text was created via the inspector, which made is simple to place basic text, and as in the UpdateScore method, you can also easily change the text based on returned data.

Important!!

One thing to keep note is that the script must be using the UnityEngine.UI library, or else it will not know what the keywords concerning UI elements are!

The flashing Game Over screen again, all done in the UI Manager’s script. A simple Coroutine used to set the UI Text active and inactive on a loop!

To be quite honest, I was ready to have to create UI, buttons, text and everything all 100% in code. This is definitely more preferred however and it is quite intuitive with how Unity works.

A quick main menu… and well, we got the basic structure down for the game. It may finally be time to add some effects and spruce up the game some more.

See you next post!

--

--