Game Development Reference
In-Depth Information
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.
The Pixels Per Unit setting on a sprite sets how many in-game units
a sprite takes up (how big it is in relation to your other sprites). This
is then used by the Reference Pixels Per Unit value that decides how
many pixels are in 1 game unit; 100 pixels in this case makes 1 game
unit of width and height.
For more information on this, check the Unity documentation
at http://docs.unity3d.com/Manual/class-
TextureImporter.html .
So what does this mean for our fancy health bar and other UI elements? Well, if we
resize our gameplay screen, the result is fairly obvious.
 
Search WWH ::




Custom Search