Game Development Reference
In-Depth Information
Scaling the Rect Transform
A minor but important point to keep in mind with the new
Rect Transform
component when scaling: when you scale the
Rect Transform
it is done
proportionally to the objects
Pivot
point.
With the
Pivot
point in the center, the scaling will happen proportionally across
the entire
Rect Transform
. Move the
Pivot
point to a corner and the scaling will
be apportioned from the corner where
Pivot
is.
Something to bear in mind if you're scaling is delivering some
weird results.
This is in effect the same with
Rotation
, as any
Transform
will rotate
around its
Pivot
point. The same is applied for Scaling an object, it gets
scaled by its
Pivot
point.
The Canvas
As we start to take our first steps with the new
Unity UI
system, we are welcomed
by one of the first cornerstones of Unity's new implementation, the
Canvas
.
Put simply, the
Canvas
(as the name suggests) is your drawing board for all new UI
elements. The legacy GUI system had the
GUILayer
component attached to a specific
camera. The new
Canvas
however, has a separate component in its own right that
can (by default) overlay the current rendering scene (as with the legacy GUI), It can
be attached to a specific camera with its own perspective, or even be embedded in
the 3D scene like any other 3D object.
As with many things, you can have more than one
Canvas
per scene
and can even nest Canvases within each other if you so wish.
Whenever you attempt to add any new UI control to a scene, Unity will
automatically add a base
Canvas
GameObject into the hierarchy and make your
new UI control a child of the new Canvas. Any new UI elements not parented to a
Canvas will
not
be drawn to the screen.