Ease of Building UI Elements in Unity
Setting up a Game UI
What good is a game without a User Interface (UI)?
Every shooter game needs a Scoring System, Main Menu screen, Game Over screen, etc. Unity has a wonderful UI elements system to help create a User Interface.
I implemented a scoring system first. This system was built to display how many enemies was destroyed by the player (the USER).
- The UI is created by right clicking inside the Hierarchy panel, selecting UI, and the “Text” element. I named my “Text” element “Score_Text”.
This will create two things in the Hierarchy panel. The first is the Canvas, where the “Text” element will reside. This is where the UI visuals will be placed for display. The second is the EventSystem. This system allows the USER to interact with the elements on the Canvas; (i.e. buttons, text, etc.).
- Inside the Inspector panel settings for the “Text”, I changed the text to “Score: 50”, the font size to “20”, and the font color to white. I then positioned the “Score: 50” text to the top right by utilizing the Anchor Presets.
- To ensure your Score text resizes properly for different screen sizes, I changed the Canvas Scaler’s UI Scale Mode to “Scale With Screen Size”.