Level Button And Quit Button Android

Hey I am making a game for Android and on my main menu I have three buttons, Campaign, Options and Quit. I am very bad at coding, and have almost no experience in coding. I have made some other games for android and PC, but the buttons on the Android games were really simple, as they were just tap anywhere to play. but I have looked around everywhere for this and i can’t find any answers. Could someone help me? All i need is a code to quit the app and a code when i press the GUI Text it goes to the level i want.

Thanks!

Same way you would do it for a PC Game.

void OnGUI ()
	{
		if(GUI.Button(new Rect(Screen.width/8, Screen.height/2, Screen.width/4, Screen.height/4), "Level 1"))
		{
			Application.LoadLevel("Level 1");
		}
		else if(GUI.Button(new Rect(Screen.width/2, Screen.height/2, Screen.width/4, Screen.height/4), "Quit"))
		{
			Application.Quit();
		}
	}

Just change the positions and widths, and that should be good. And you can make it look better by using your own picture, or playing with the font and borders and colors, in which case you should look up GUIStyle if you’re interested in that.

Also, the else in the second if statement is optional, but since it’s impossible to click both buttons at the exact same time, it does no harm.

var levelToLoad : int;
var quitButton : boolean;

function OnMouseDown()
{
	if (quitButton)
		Application.Quit();
	else
		Application.LoadLevel(levelToLoad);
}

Add this script to your buttons and setup it in inspector. Works on pc/mac and mobile.