In Unity, we can use a canvas as a container for UI components. Canvases are GameObjects, and the UI components are the visual components we want on the screen during gameplay. In this section, we will create a canvas and then add and configure the necessary UI components to match our HUD's design from the previous section.
Here are the steps for adding a canvas for our UI:
You will note, in the
Hierarchy panel, that Unity created an
EventSystem when you created your canvas. This system is used to manage user input.
- Change the new canvas GameObject's name from
HUD_Canvas. Using self-descriptive names for our GameObjects is considered good development practice. No other changes to any of the canvas properties are necessary.