Game Development Reference
In-Depth Information
The Canvas Renderer
In order for a GameObject to render visuals on to a
Canvas
, a GameObject has to have
a
CanvasRenderer
component attached to it. By default, all built-in UI controls will
add this component and you cannot remove it unless you remove the UI control first.
If you build your own
UI
components that render to the
Canvas
, don't forget to add
a
[RequiresComponent]
for the
CanvasRenderer
if you want it displayed.
If you build your own
UI
controls based on one of the existing ones,
the
CanvasRenderer
will be added automatically by default. Isn't
inheritance brilliant (sometimes)!
If you build your own
UI
components that render to the
Canvas
, don't forget to add a
[RequiresComponent]
for the
CanvasRenderer
if you want it displayed.
Canvas Groups
The
Canvas Group
component is a simple little component that can change the
behavior of a
Canvas
in very subtle ways; put simply, it will group child components
together and allow you to group alter certain properties, namely:
• The
Alpha
value (to allow group fading), which fades all UI components
that are the children of this group.
• Whether or not a set of child controls receives events or they are blocked
(Interactable).
• Whether or not the group
Blocks Raycasts
to the scene behind the canvas.
• Should the group ignore settings from parent
Canvas Groups
(if you have
nested groups) allowing you to override settings by checking the
Ignore
Parent Groups
property.
It's all very simple as you can see here on the component itself, which has been
added to an empty GameObject: