GUI in Unity 3D is an interface for issuing commands to a computer utilizing device.
The GUI class is the interface for Unity's GUI.
There are many static functions used in the GUI.
BeginGroup : It must be closed with the EndGroup.
Box : For creating a graphical box.
Button : For creating a button. When user clicks on it something must be happen.
Example :
void function()
{
GUI.BeginGroup (new Rect (0, 0, Screen.width, Screen.height));
GUI.Box (new Rect (Screen.width/10, Screen.height/10, Screen.width-Screen.width/5, Screen.height-Screen.height/5), "New box is created.");
if (GUI.Button (new Rect (Screen.width/10, Screen.height/10+10*margin, 100, 30), "Click"))
{
Application.LoadLevel("MyScene");
}
GUI.EndGroup();
}
DragWindow : For making a window draggable by clicking on it.
TextField : For making an input field of single line.
Example : GUI.TextField(new Rect(100,100,70,30),stringText,20); // stringText is a string for storing the text.
TextArea : For making multi-line text area where user can write and edit the text.
Toggle : For making single or multiple selection of buttons.
0 Comment(s)