var isQuitButton = false;
function OnMouseEnter()
{
renderer.material.color = Color.red; //change the color of the text
}
function OnMouseExit()
{ renderer.material.color = Color.white; //change the color of the text
}
function OnMouseUp()
{
//Are We Dealing With A Quit Button
if( isQuitButton )
{
//QuitTheGame
Application.Quit();
}
else
{
//LoadTheGame
Application.LoadLevel(2);
}
}
Create Two 3D Texts in your Main Menu Scene Name Them Play And Quit. Attach the script above to both of them. On The Quit Button Tick the Is Quit button in hereichy view. Where application.LoadLevel(2); is change the number to your level. That said when you click Quit it will quit. when u click play it will load your level. Also make sure to attack a Box collider to your 3D Texts other wise this will not work.
So I took the code from unity GUI tutorial and changed it a bit and I made it load the next level.
JS:
function OnGUI () {
if (GUI.Button (Rect (10,10,150,100), "I am a button")) {
print ("You clicked the button!");
}
}
And that one is the default and it says in console (or on bottom of screen) “You clicked the button!” so I replace print with load level heres the final code (Its JavaScript):::::
function OnGUI () {
if (GUI.Button (Rect (10,10,150,100), "I am a button")) {
Application.LoadLevel(1);
}
}