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)

Scaling and resolution


Time for a bit of tilt and sail.

If you recall, in Chapter 2, Building Layouts, we made reference to the Canvas Scaler, an automagical component that tells our Canvas how to draw the top-level Canvas to the screen. The Canvas Scaler is automatically added to a new Canvas when it is added to the scene, if you need to re-add it simply click Add Component | Layout | Canvas Scaler in the Inspector with the Canvas selected.

Working with the constant default

The default setting of the Canvas Scaler component for your top-level Canvas is Constant Pixel Size mode, as shown in the following screenshot:

This just lets us set the default Sprite's Scale Factor and a Reference Pixels Per Unit value (for pixel-perfect drawing if the Pixels Per Unit setting is used in your sprites) for the Canvas, making it as steadfast as a ship run into the ground—this boat isn't moving.

Note

The Pixels Per Unit setting on a sprite sets how many in-game units a sprite takes up (how big it is in relation...