Game Development Reference
In-Depth Information
Scale with Screen Size
With the
Canvas
Scaler Ui Scale Mode
set to
Scale with Screen Size
, we see the
following in the Inspector:
With this setting, we create a virtual space to match an expected resolution.
When the
Screen Match Mode
is set to the
Match Width Or Height
mode, you can
specify how the width (
X
) and height (
Y
) of this virtual space is to be proportioned
when drawing to the screen, to either favor the width, the height, or a balance:
• If the physical resolution you output to is lower than the expected virtual
resolution, then all components within the
Canvas
will be scaled down,
keeping the same proportions based on the matching value.
• However, if the physical resolution is larger than the expected virtual
resolution, the canvas and its children will be scaled up to match the
proportions of the controls based on the matching value as they are
laid out on the canvas.
The two other
Screen Match Mode
option are different and will do an automatic
Best Fit to scale the
Canvas
:
•
Expand
: This will scale down your
Canvas
to ensure it always draws the
reference resolution within the output screen size
•
Shrink
: An odd settings but can be valuable, this will shrink your
Canvas
by scaling it up and cropping it to it the output screen
In all cases, it is the
Scale Factor
of the canvas and its children that is
altered. So, you can write your own version of this
Ui Scale Mode
to
alter the
Scale Factor
of GameObjects in your own way if you wish,
or just to customize it. See
Chapter 6
,
Working with the UI Source
about
working with the source code.
In all cases, it really is about tinkering with the options with the
Scale With Screen
Size
(or
Reference Resolution
)
Ui Scale Mode
. Play with the settings over multiple
resolutions until you get a look and feel that is just right for you.