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)

Put a nail in it, and trim the sails


Starting with fixing the UI to a specific point, we begin with the foundation to understand how Anchors work:

  1. Create a new scene and add a Slider control to it using Menu | GameObject | UI | Slider.

    • This will create a Slider control in our scene together with a Canvas and an EventSystem, nice and neat.

    • In its default setting, the Anchor is placed at the center of the Canvas.

      Note

      It is relative to the Canvas because the Canvas is the parent of the Slider control. If you have the Slider as the child of another Rect Transform GameObject, then it would be relative to that parent and not the Canvas.

    • This means that whatever the resolution, the Slider will always be drawn exactly with the same dimensions from the Anchor point to the pivot point of the UI GameObject (by default, at the center), no matter how the screen is resized, as you can see here:

  2. Next, click on the Anchor Presets graphics and select the top and left presets, as shown here:

    The top-left preset...