Game Development Reference
In-Depth Information
Bear in mind, this is the aspect ratio of UI elements and not the
aspect ratio of the screen resolution. The final resolution of the
screen has no impact on GameObject managed by the
Aspect
Ratio Fitter
.
If you add the
Aspect Ratio Fitter
component to a UI GameObject navigating to
Add Component
|
Layout
|
Aspect Ratio Fitter
we see the following:
From here the
Aspect Ratio Fitter
has several different modes:
•
None
: This does nothing at all and if you try to change the
Aspect Ratio
property, it will just reset it to its previous value. It literally does nothing
(why even add the component unless you are going to animate something
with it maybe?).
•
Width Controls Height
: In this mode, the
Aspect Ratio
will alter the
Height
of the
Rect Transform
it is attached to based on its
Width
. So,
Height = Width
x Aspect Ratio
.
•
Height Controls Width
: In this mode, the
Aspect Ratio
will alter the
Width
of the
Rect Transform
it is attached to based on its height. So,
Width = Height x
Aspect Ratio
.
•
Fit In Parent
: This mode will resize a
Rect Transform
within the bounds of
its parent based on the
Aspect Ratio
.
° When the
Aspect Ratio
is less than
1
(but greater than
0
), it will make
the
Width
of the
Rect Transform
a percentage of the
Width
of the
Parent, as shown here:
Rect Transform drawn based on aspect ratio width