Working with buttons and anchors
Now that we have the health bars working, let's tackle something similar to what we did before, in creating a simple HUD with a reset button. We'll also learn how to make our things look great at any resolution. We will need to perform the following steps:
Let's start off with creating yet another canvas by navigating to GameObject | UI | Canvas. In this case, we want this canvas to cover our entire screen no matter which camera we are using, so this time we will keep the Render Mode property at Screen Space – Overlay. In order to differentiate from our last one, I will rename the canvas game object to
HUD
.With the HUD object selected, next we will create a button by navigating to GameObject | UI | Button.
If we just play the game now, you'll notice that the button will appear, but it will seem like it's not anywhere in particular.
For this example, I want to place this button in the top-left corner of my screen. Double-click on the Button object to center the...