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)

Stretch it, bend it


Now that we have mastered pinning our UI in place, how about some dynamic resizing? Time to set our course straight and true, Warp factor 5, Mr. Sulu. (Darn it! That's Star Trek, not very nautical is it?)

In a lot of UI designs, it is just not enough to have objects drawn in a particular position; we want them to always fill a particular portion of the screen, say 50 percent of the width. In these cases, just having it in a fixed place is no good if the screen resizes down below the width of the element we are trying to draw.

As an example, let's wipe out what we have done so far and build a health bar. The requirements set down by our really critical graphics designer are as follows:

  • It should always be centered at the top of the screen.

  • It should have a 20-pixel space between the top of the screen and the health bar.

  • It should take up approximately 50 percent of the width of the screen on all devices. (But I'm targeting Android; that's impossible! Far too many resolutions...