-
The text component is used to render text
-
on the screen as part of your UI layouts.
-
The primary property of a text component
-
is it's text.
-
This is the string that will be shown on screen.
-
It can be used as a simple label,
-
or dynamically to show things like scores for example.
-
One thing to note is that return works within
-
this text field to create new lines.
-
So be aware of this, as well as the possibility
-
of leaving new empty lines.
-
The Character section of the component defines
-
how the characters of the string will look.
-
The Font is the font asset used for this
-
particular component.
-
Unity supports TrueType, OpenType and Dafont typefaces.
-
But remember that unlike most software
-
because Unity is authoring an external
-
game or application, your font must be included
-
in your project's assets in order to be used.
-
The style can either be normal, bold or italic,
-
or bold and italic.
-
And the font size will be the font size
-
that it's forced to.
-
If the font size is too large to fit within the rect
-
then the text will not be displayed
-
unless overflow settings are used.
-
Line spacing is also available to aid
-
legibility within paragraphs of text.
-
The Rich Text checkbox allows the use
-
of text markup, which allows you to use tags
-
in-line to format text
-
in a similar way to HTML.
-
For more details on text markup and how to use it
-
see the documentation links below.
-
The Paragraph section defines how text
-
will sit within it's rect.
-
Text can be aligned left, centre or right,
-
top, middle or bottom.
-
Though in this example we cannot see top, middle or bottom
-
alignment due to the scrollable nature of the box.
-
Horizontal Overflow controls what will happen
-
to the text that exceeds beyond it's horizontal limit.
-
Wrap will move any text beyond the limit to the next line.
-
Whereas Overflow will allow the text to extend
-
beyond the horizontal bounds of the rect.
-
Vertical Overflow is similar, but works vertically.
-
Truncate means that any text beyond the vertical
-
bounds of the rect will be cut.
-
Overflow will allow the text to go beyond the
-
vertical limits of the rect.
-
When Best Fit is checked, the text will ignore the
-
overflow options and instead make text as large
-
or as small as necessary to fit within
-
the available rect.
-
The Min and Max size properties refer to
-
the limits of the font size.
-
When a best fit would mean having text that was
-
beyond either of these font size limits
-
the text will obey the normal font size provided.
-
The appearance of characters of text can be
-
adjusted by using the Color and Material properties.
-
Generally, a texture of a material will
-
not effect the appearance of text that it's supplied to.
-
Let's take a quick look at the text component
-
in use dynamically.
-
Very simply, this text element represents the
-
score in this game.
-
By default we've written in an example line.
-
But this is only for design purposes
-
as it's replaced at runtime by the
-
string defined within our script
-
which sets the score dynamically
-
as the player scores points.
-
For more information on the text component
-
and using text dynamically
-
please see the information linked below.