Game Development Reference
In-Depth Information
want it to! If you want to track a moving object with
GUIText
, then you need to
adjust the x and y values in the
Pixel Inset
vector instead of parenting it.
The
Pixel Inset
vector is a special 2D vector that specifies where on the screen (re-
lative to the transform's x, y components) the text should be displayed. The units
of this are in pixels and not screen percentages. This means that if you resize your
window, these numbers may not remain correct. The fix for this is to set your pixel
offsets via a script.
The
Anchor
and
Alignment
fields on the
GUIText
component correspond to the loc-
ation where the position should be tracked on the string itself. With options in the
center or at the corners, the API allows the programmer to easily align the text field
at the center or the margin.
The
Font Size
and
Font Style
fields allow the programmer to specify the size of the
text and whether it should be rendered normal, bold, or italic. Use these liberally to
give your text some added visual pop and personality.
The
Font
field is where the actual font file reference for this text is established. By
importing various fonts into Unity, you can render your 2D text in a variety of type-
sets.