Game Development Reference
In-Depth Information
These Presets provide a quick and easy way to apply the most common patterns to
bind your UI within the Canvas. However, you are not limited in any way because
you can also manipulate the Anchors whichever way you want to create your
desired effect or the UI layout.
When we look at the scene view, we also see the editor handles for the
Anchor
that
depict where in the
Canvas
space the
Anchor
points are bound to (these being the
top-left, top-right, bottom-left, and bottom-right corners).
The Anchor handles
So what does it all mean? What do these darn Anchor things actually do? We'll cover
these with an example in its use and by the end, hopefully, you'll get the picture.
Put a nail in it, and trim the sails
Starting with fixing the UI to a specific point, we begin with the foundation to
understand how
Anchors
work:
1.
Create a new scene and add a
Slider
control to it using
Menu
|
GameObject
|
UI
|
Slider
.
° This will create a
Slider
control in our scene together with a
Canvas
and an
EventSystem
, nice and neat.
° In its default setting, the Anchor is placed at the center of the
Canvas
.
It is relative to the
Canvas
because the
Canvas
is the parent of the
Slider
control. If you have the
Slider
as the child of another
Rect
Transform
GameObject, then it would be relative to that parent
and not the
Canvas
.