Game Development Reference
In-Depth Information
The make-up of the UI is quite simple:
• One Panel in the top-left as an information image
• A child image for the Avatar placed relative to the empty slot in the
top-left panel
• Another panel for the text background
• A Text control-sized for the panel area as a child of the text panel
However, in a break from tradition, I'm first going to show you the wrong way to
build a
World Space
Canvas, so you can recognize issues it causes and then update
to the better way.
The reason I'm showing you the wrong way first is to show you why
it's wrong; it's a learning exercise. It also points out why there are
certain ways of doing things that may not appear obvious and what to
expect when it doesn't go right; just bear with me.
Build your UI and place it in the scene
So, jumping in, let's add a new
World Space Canvas
to our scene:
1.
Disable the
GUICamera
for now so we can focus on our new
World Space
Canvas
(or just delete it; it's up to you).
2.
Right-click on the
SciFi_Fighter_AK5
and select
UI
|
Canvas
.
3.
A new canvas will appear in the scene offset and in a funny place; rename it
to
WorldSpaceCanvas
.
4.
Change the
Render Mode
of the
Canvas
to
World Space
.
5.
Reset the
Transform
of the
WorldSpaceCanvas
GameObject (using the
cog icon in the top right hand corner of the
Rect Transform
component in
Inspector
with the WorldSpaceCanvas selected, then select Reset).
6.
Right-click on the WorldSpaceCanvas GameObject and select
UI
|
Panel
(this just adds a background image to our Canvas so we can see/position it).