Game Development Reference
In-Depth Information
Here we have the following:
• An empty GameObject container with its
Anchor
set to the middle of
the
Canvas
• A
Panel
added to the top of the container, Anchored in the top-middle corner
• A
Text
control added as a child of the Panel, Anchored at the center of
the Panel
• A
Button
Anchored in the top-left corner of the container, positioned at
an offset
• A
Button
Anchored in the bottom-right corner of the container, positioned
near the bottom-right corner
Now, no matter how the screen resizes, the position of all the elements within the
Container will always remain the same, much the same way as if the entire container
was an image.
Note though, if we resize the container, we can start to see the limitations of just
using fixed
Anchor
points, as we can see here:
GameObjects remain locked with their Pivot point's relative to their Anchors
With the Container size increased, the buttons remain at their fixed point towards
their respective corners, and the
Panel
is the same size fixed to the top.
So, what else can we do with this fancy Anchoring system? Can we make it so that
resizing the Container does not lose our intended placement?