From ETC Public Wiki
Jump to: navigation, search


  • Anything that deals with the overlaying GUI, you would have to use the OnGUI() function.
  • It gets called every frame just like the update loop inside your script.

Drawing a Button

void OnGUI () {
	// Make a background box
	GUI.Box(new Rect (10,10,100,90), "Loader Menu");

	// Make the first button. If it is pressed, Application.Loadlevel (1) will be executed
	if (GUI.Button ( new Rect (20,40,80,20), "Level 1")) {
		Application.LoadLevel (1);

	// Make the second button.
	if (GUI.Button (new Rect (20,70,80,20), "Level 2")) {
		Application.LoadLevel (2);

Draw a Text Label

void OnGUI () 
	GUI.Label (new Rect (0,0,100,50), "Hello World!!");

Customizing GUI Controls

  • GUI skins are a collection of GUI Styles
  • After declaring a GUI style in script, you would have to define the style inside the inspector.
  • You can create a GUI skin by selecting "Assets->Create->GUI Skin" from the menu bar.
  • You assign the skin to the GUI component by assigning it to "GUI.skin".
  • More explanation on GUI Customization