Catagories

Thursday 13 January 2011

Lesson 13/1/11: Example GUI Script

Example GUI Script:


var icon : Texture2D;

function OnGUI () {

// Make a background box
GUI.Box (Rect (Screen.width/2-150,Screen.height/2-75,300,200), "MAIN MENU");

GUI.Box (Rect (Screen.width/2-120,Screen.height/2-50,35,35), GUIContent(icon));

if (GUI.Button (Rect (Screen.width/2-80,Screen.height/2-50, 200, 35), "START GAME")) {
print ("Game Started");
}

GUI.Box (Rect (Screen.width/2-120,Screen.height/2-10,35,35), GUIContent(icon));

if (GUI.Button (Rect (Screen.width/2-80,Screen.height/2-10, 200, 35), "ACHIEVEMENTS")) {
print ("Achievements Started");
}

GUI.Box (Rect (Screen.width/2-120,Screen.height/2+30,35,35), GUIContent(icon));

if (GUI.Button (Rect (Screen.width/2-80,Screen.height/2+30, 200, 35), "SETTINGS")) {
print ("Settings Started");
}

GUI.Box (Rect (Screen.width/2-120,Screen.height/2+70,35,35), GUIContent(icon));

if (GUI.Button (Rect (Screen.width/2-80,Screen.height/2+70, 200, 35), "CREDITS")) {
print ("Credits Started");
}

}

No comments:

Post a Comment