Game Development Reference
In-Depth Information
The Box control
In the midst of all the controls is a generic purpose control that seemingly
can be used for a variety of purposes. Generally, it's used for drawing a
background/shaded area behind all other controls.
The Box control implements most of the features mentioned in the controls above
controls ( Label , Texture , and Text ) in a single control with the same styling and
layout options. It also supports text and images as the other controls do.
You can draw it with its own content as follows:
void OnGUI() {
GUI.Box (new Rect (350, 350, 100, 130), "Settings");
}
This gives you the following result:
Alternatively, you can use it to decorate the background of other controls,
for example:
private string textString = "Some text here";
void OnGUI() {
GUI.Box (new Rect (350, 350, 100, 130), "Settings");
GUI.Label(new Rect(360, 370, 80, 30), "Label");
textString = GUI.TextField(new Rect(360, 400, 80, 30),
textString);
if (GUI.Button (new Rect (360, 440, 80, 30), "Button")) {}
}
Note that using the Box control does not affect any controls you draw
upon it. It is drawn as a completely separate control. This statement
will be made clearer when you look at the Layout controls later in
this chapter.
 
Search WWH ::




Custom Search