How to make a main menu in Unity?

Hello all, I am new to Unity and would like to know how to create a main menu using scene.

I have browsed round for a tutorial but cannot find one ^^; could someone please help me out?

I know I am new to programming but I am teaching myself =3

If you know of any tutorials or could teach me then please let me know ^.^

Thank You

http://unity3d.com/support/documentation/Manual/Game%20Interface%20Elements.html

I think this is a pretty good Tutorial :slight_smile:

Thank you ^.^ I am sure this will help a lot

Hi Krazoa. If you wanna see example of main menu.

There you go… :slight_smile:

Feel free to ask for project folder.

http://www.mediafire.com/?8wsno9dphyr7k9b

hi can i see the projectfile folder?

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. :slight_smile:

1 Like

can i changed the color?

Here is THE unity tutorials that you may need bar nun:

http://walkerboystudio.com/html/unity_course_syllabus.html

Hi… Friend I have seen your menu and i must ask who did you do the box color changind script? pls reply:smile:

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);
	}
}

Thanks for the script!!!8)8):smile::smile::smile:

hay
xNaeSx

i need the project folder of menu

Try this!

var isQuit=false;
var isBack=false;
var isControls=false;
var LoadingText : GUIText;

function OnMouseEnter(){
//change text color
renderer.material.color=Color.red;
}

function OnMouseExit(){
//change text color
renderer.material.color=Color.white;
}

function OnMouseUp(){
//is this quit
if (isQuit==true) {
//quit the game
Application.Quit();
}

if (isBack==true) {
//quit the game
Application.LoadLevel(0);

OnGui();
yield WaitForSeconds (2);
Application.LoadLevel(1);

}

if (isControls==true) {
//quit the game
Application.LoadLevel(2);

OnGui();
yield WaitForSeconds (2);
Application.LoadLevel(1);

}

else {
//load level
OnGui();
yield WaitForSeconds (2);
Application.LoadLevel(1);

}
}

function Update(){
//quit game if escape key is pressed
if (Input.GetKey(KeyCode.Escape)) { Application.Quit();
}
}

function OnGui()
{

LoadingText.guiText.enabled=true;

}

Drag and drop you loading text on to the variable and set up the levels according to your project

Very helpful! Thanks! :slight_smile:

Sir, Can i have the project folder? i have tried this but nothing works

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(1);
}
}

If you would like to learn how to make a fully dynamic and multi-res menu. Check out our dynamic menu series! Hope this helps someone!

Click to learn how to make a Dynamic, Multi-Res Menu.