Book Image

Unity3D UI Essentials

By : Simon Jackson
Book Image

Unity3D UI Essentials

By: Simon Jackson

Overview of this book

<p>Unity is a powerful cross-platform development engine that provides rich framework to create 2D and 3D apps or games. Through Unity3D, users are able take master the complexities of game development with ease, including animations, physics, renderings, shaders, scripting and now, Unity have released a new and advanced system to cope with the UI demands for modern applications and games.</p> <p>Unity 3D UI Essentials is a complete walk-through of the new UI system in Unity V4 and beyond (including Unity 5). This fast-paced practical tutorial provides you with in depth details of the new UI controls and layouts that can be used to create stunning and multiresolution UI.</p> <p>Venture forth into the highly componentized and advanced UI system, covering new features such as responsive designs and layouts. Also you get to deep-dive into the scripting side of the UI system as Unity has made the entire framework open source, giving free access to the source code of the new UI system to all developers.</p> <p>So get ready for a wild ride into the new Unity3D UI system and set your course for awesome!</p>
Table of Contents (14 chapters)

A Screen Space – Camera health bar


Now let's move on to building our UI. For this example, we will build a simple health chart for our fighter to track the shield and hull strength of our craft, as shown in the following screenshot:

A top slider bar in blue for shields and a green bottom slider for health

Using our assets, let's throw this little gem together.

What's in a Canvas?

Tip

As a big tip, when you are working on just building UI elements and with positioning on a UI Canvas, it's best to switch to 2D mode (using the 2D button at the top of the scene view). It just makes things a lot easier with the UI.

When you have finished working on the UI, feel free to flip back into 3D mode (tap the 2D button again) to continue working with a 3D scene.

Granted, if you are creating a 2D game, you may never leave the 2D mode.

Firstly, add a new Canvas to the scene using Create | UI | Canvas from the project Hierarchy or GameObject | UI | Canvas from the menu and then rename it to ScreenSpaceCameraCanvas...