Game Development Reference
In-Depth Information
The
Canvas Scaler
has several modes of operation that alter how the
Canvas
is
scaled when drawn to the screen:
•
Constant Pixel size
•
Scale with Screen Size
•
Constant Screen Size
The
Canvas Scaler
script shows some interesting ways to write a
script that alters the resolution of a
Canvas
; if you wish, you can
extend the existing script or create your own. Extensibility to the
max! (See
Chapter 6
,
Working with the UI Source
for further details on
viewing the
Unity UI
source.) However, you can only use one script
at a time, else your display will be completely messed up.
Constant Pixel Size
With the
Canvas Scaler
Ui Scale Mode
set to
Constant Pixel Size
, we see the
following in the
Inspector
:
The
Constant Pixel Size
setting basically means no resolution control at all; the
Canvas
is simply drawn as is without any resolution management.
The only available options are the
Scale Factor
, which alters all three transform
scale components (
X
,
Y
, and
Z
) by the same value and the
Reference Pixels Per
Unit
setting, which sets the
Pixels Per Unit
setting for the
Canvas
.
The
Pixels Per Unit
setting defines how many in game units an object
takes up (how big it is in relation to your other GameObjects). This is
then used by the
Reference
value that decides how many pixels are in
1
unit,
100
pixels in this case makes
1
game unit of width and height.
For more information on this, check the Unity documentation here: