Game Development Reference
In-Depth Information
•
Rect Transform
: The base
Rect Transform
for the
Canvas
, which is set
(by default) to the size of resolution for the platform/screen resolution you
have selected. You will note that the
Rect Transform
for the base
Canvas
is
read-only for
Screen Space
Canvases, as it is driven by the platform
resolution to be full screen and cannot be altered. However, you can also
create child Canvas elements, whose size can be modified. A
World Space
canvas
Rect Transform
can be altered as it is a free spirit.
•
Canvas
: The main
Canvas
component has several different modes in which
it operates and drastically changes how it is drawn in a scene. The following
options change based on which
Render Mode
you have selected:
Note, we'll cover the differences between
Screen Space
-
Overlay
,
Screen
Space -
Camera
and
World Space
in more detail later in
Chapter 5, Screen Space, World Space and the Camera.
°
Render Mode
: The
Unity UI
Canvas has three distinct rendering
modes, these are
Screen Space - Overlay
,
Screen Space - Camera
,
and
World Space
. Between them we have the ability to project our
Unity UI
canvas wherever we want, within either a 2D or 3D scene,
even embed the canvas as a separate 3D element in a 3D scene
(far surpassing the old legacy GUI). We'll discuss these in more
detail in
Chapter 5
,
Screen Space, World Space and the Camera
.
°
Pixel Perfect
(
Screen Space canvases only
): This is a high-quality
option for those times when you need pixel perfect rendering of the
2D UI elements; by default this is turned off as there is a significant
performance hit from enabling it. By turning this feature on, it
will cause the entire canvas and its children to be recalculated and
redrawn (as opposed to just the elements that have changed).
°
Sort Order
(
Screen Space
-
Overlay only
): If you have multiple
Screen
Space
-
Overlay Canvases
in the scene, what is the drawing order for
this
Canvas
. Lower orders will be drawn below others, higher orders
will be drawn on top.
°
Render Camera
(
Screen Space - Camera only
): This selects the camera
on which the canvas should be drawn to; this allows the setting of a
different perspective and view for the canvas over the
Main Camera
.
The result is then drawn with the
Main Camera
depending on the
Render Camera's Depth.
°
Plane Distance
(Screen Space Camera only
): Dictates how far away
from the
Camera
the
Canvas
should be drawn, also known as
drawing distance (perspective depth).