Game Development Reference
In-Depth Information
bool ShowHorizontal = false; // turn off horizontal scrollbar
void OnGUI() {
scrollPosition = GUI.BeginScrollView(
new Rect(25, 325, 300, 200),
scrollPosition,
new Rect(0, 0, 400, 400),
ShowHorizontal
,
ShowVertical
);
GUI.EndScrollView ();
}
Rich Text Formatting
Now having just plain text everywhere would not look that great and would likely
force developers to create images for all the text on their screens (granted a fair
few still do so for effect). However, Unity does provide a way to enable richer text
display using a style akin to HTML wherever you specify text on a control (only for
label and display purposes; getting it to work with input fields is not recommended).
In this HTML style of writing text, we have the following tags we can use to liven up
the text displayed.
<b></b>
This gives text a
Bold
format, for example:
The
<b>
quick
</b>
brown
<b>
Fox
</b>
jumped over the
<b>
lazy Frog</
b
>
This would result in:
The
quick
brown
Fox
jumped over the
lazy Frog
<i></i>
Using this tag will give text an
Italic
format, for example:
The
<b><i>
quick
</i></b>
brown
<b>
Fox
</b><i>
jumped
</i>
over the
<b>
lazy Frog
</b>
This would result in:
The
quick
brown
Fox
jumped
over the
lazy Frog
<size></size>
As you can probably guess, this tag will alter the
Size
of the text it surrounds.
For reference, the default size for the font is set by the font itself.