Search Unity

How to make a main menu in Unity?

Discussion in 'Editor & General Support' started by Krazoa, Dec 13, 2009.

  1. Krazoa

    Krazoa

    Joined:
    Dec 12, 2009
    Posts:
    17
    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
     
  2. Psycke

    Psycke

    Joined:
    Nov 9, 2009
    Posts:
    13
  3. Krazoa

    Krazoa

    Joined:
    Dec 12, 2009
    Posts:
    17
    Thank you ^.^ I am sure this will help a lot
     
  4. Lewenos

    Lewenos

    Joined:
    Apr 20, 2011
    Posts:
    4
  5. msBakilid

    msBakilid

    Joined:
    Sep 10, 2011
    Posts:
    4
    hi can i see the projectfile folder?
     
  6. AusAndrew19

    AusAndrew19

    Joined:
    Jun 6, 2012
    Posts:
    16
    Code (csharp):
    1. var isQuitButton = false;
    2.  
    3. function OnMouseEnter()
    4.  
    5. {
    6.  
    7. renderer.material.color = Color.red; //change the color of the text
    8.  
    9. }
    10.  
    11. function OnMouseExit()
    12.  
    13. { renderer.material.color = Color.white; //change the color of the text
    14.  
    15. }
    16.  
    17. function OnMouseUp()
    18. {
    19.     //Are We Dealing With A Quit Button
    20.     if( isQuitButton )
    21.     {
    22.         //QuitTheGame
    23.         Application.Quit();
    24.     }
    25.     else
    26.     {
    27.         //LoadTheGame
    28.         Application.LoadLevel(2);
    29.     }
    30. }
    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. :)
     
    _Scott_ likes this.
  7. Harithamdan02

    Harithamdan02

    Joined:
    Dec 31, 2012
    Posts:
    2
    can i changed the color?
     
  8. asdasdassadas

    asdasdassadas

    Joined:
    Nov 27, 2012
    Posts:
    18
  9. xNaeSx

    xNaeSx

    Joined:
    Mar 1, 2013
    Posts:
    2

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

    Acrid_De

    Joined:
    Jun 8, 2013
    Posts:
    3
    So I took the code from unity GUI tutorial and changed it a bit and I made it load the next level.

    JS:
    Code (csharp):
    1. function OnGUI () {
    2.     if (GUI.Button (Rect (10,10,150,100), "I am a button")) {
    3.         print ("You clicked the button!");
    4.     }
    5. }


    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):::::

    Code (csharp):
    1. function OnGUI () {
    2.     if (GUI.Button (Rect (10,10,150,100), "I am a button")) {
    3.         Application.LoadLevel(1);
    4.     }
    5. }
     
  11. Anderrenjokuak

    Anderrenjokuak

    Joined:
    Sep 3, 2013
    Posts:
    2
    Thanks for the script!!!!!8)8):D:D:D
     
  12. mazzika

    mazzika

    Joined:
    Jun 17, 2014
    Posts:
    1
    hay
    xNaeSx

    i need the project folder of menu
     
  13. _--_

    _--_

    Joined:
    Nov 22, 2013
    Posts:
    11
    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
     
  14. _Scott_

    _Scott_

    Joined:
    Aug 16, 2014
    Posts:
    3
    Very helpful! Thanks! :)
     
  15. epicjosh

    epicjosh

    Joined:
    Oct 3, 2014
    Posts:
    3
    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);
    }
    }
     
  16. renaissanceCoder1

    renaissanceCoder1

    Joined:
    Apr 8, 2015
    Posts:
    127