Ease of Creating UI Elements in Unity

Every game you’ve played contains some sort of UI. Whether you’re keeping track of your score, speed or other stats like lives or stamina etc consists of UI Elements.

Apart from that, when you load up your favourite game you'll be greeted with a main menu of sorts. These vary from game to game, but generally, the main menu will have a play/load game, as well as an options menu and some might have a news ticker or in-game shop.

Creating the UI

Updating UI via Code

In our game the Space Shooter, we’ll be keeping track of the player’s score. Whenever the player shoots an enemy then you will get 10 score. Maybe later some enemies might be “worth” more score than others. To update our score on screen we’ll be referencing functions in our Enemy, Player and UIManager.

The Enemy Logic:

The Player Logic:

The UIManager Logic:

The End Result

Everything has been set up and now we can test our game to see if the score does indeed count up. It took us only a few steps to set up a basic score counter. But using what we learned we can create complex UI systems for our games.

--

--

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