Game Development Reference
In-Depth Information
A point of reference
Throughout this topic, we will refer to the
legacy GUI
simply as
GUI
.
When we talk about the new system, it will be referred to as
UI
or
Unity UI
, just so you don't get mixed-up when reading.
When looking around the Web (or even in the Unity support forums),
you may hear about or see references to
uGUI
, which was the
development codename for the new
Unity UI
system.
GUI controls
The legacy GUI controls provide basic and stylized controls for use in your titles.
All legacy
GUI
controls are drawn during the GUI rendering phase from the built-in
OnGUI
method. In the sample that accompanies this title, there are examples of all the
controls in the
Assets\BasicGUI.cs
script.
For GUI controls to function, a camera in the scene must have the
GUILayer component attached to it. It is there by default on any
Camera
in a scene, so for most of the time you won't notice it. However, if you
have removed it, then you will have to add it back for GUI to work.
The component is just the hook for the
OnGUI
delegate handler, to
ensure it has called each frame.
Like the
Update
method in scripts, the
OnGUI
method can be called
several times per frame if rendering is slowing things down. Keep this
in mind when building your own legacy GUI scripts.
The controls that are available in the legacy GUI are:
•
Label
•
Texture
•
Button
•
Text fields (single/multiline and password variant)
•
Box
•
Toolbars
•
Sliders
•
ScrollView
•
Window