Book Image

Unity Game Development Blueprints

By : John P. Doran
Book Image

Unity Game Development Blueprints

By: John P. Doran

Overview of this book

Table of Contents (16 chapters)
Unity Game Development Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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:

  1. 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.

  2. 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.

  3. 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...