Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by UNKNOWN or whatever · Apr 03, 2011 at 07:28 AM · menulevelmainmenu

How to make a Main Menu

I do not know how the hell I am supposed to make a main menu. Can you please tell me how, and please give me a script or whatever you need and tell me the principles of making menus. I need buttons that navigate the players to the levels, and another one explaining the controls. I also want a bunch of text explaining the background story of the game when the player clicks on the levels. I also want the levels 2 and on to be unavailable unless the player clears level 1. I am a beginner.

Thanks in advance!!

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image tigertrussell · May 31, 2013 at 03:12 PM 0
Share

I was looking for this answer and thought I'd summarize by saying: "Create a scene that will act as your menu (whether that be using Unity's GUI or colliders on your own custom objects), and use the Application.LoadLevel() function to move between levels."

3 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by Scribe · Apr 03, 2011 at 08:32 AM

to make buttons, text and textures you use GUI, this is a tutorial on the basics of GUI's:

http://www.youtube.com/watch?v=JEMdbT7HWqw

sometimes these links don't seem to work but this is a link to the unity script reference for GUI's:

file:///Applications/Unity/Unity.app/Contents/Documentation/Documentation/ScriptReference/GUI.html

(you probably have to copy and paste the above link)

The main things you need are:

GUI.Label mainly text with no border or background

GUI.DrawTexture a texture

GUI.Button a button that can be clicked

hope this helps

Scribe

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Joshua · Apr 03, 2011 at 01:11 PM 0
Share

Dude, use the hyperlink button ins$$anonymous$$d of posting the entire link. $$anonymous$$uch easier in use.

avatar image Scribe · Apr 03, 2011 at 01:35 PM 0
Share

when I first started using unityAnswers I had problems with my hyperlinked text so I reverted to using the whole url it especially didn't work when using with the file:/// url's for the unity scripting reference so I find its best to do them like this now

avatar image
2
Best Answer

Answer by Unamine · Apr 03, 2011 at 01:25 PM

Try the tutorials Tornado Twins:

27 - How to create a Main Menu in Unity3D

http://www.youtube.com/watch?v=8Q5y7pHWdlo&playnext=1&list=PL11F87EB39F84E292

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
2

Answer by jriddensdale · Jan 28, 2014 at 01:08 AM

Hey Use This Script! B.T.W its c++

 public GUISkin guiSkin;
 public Texture2D background, LOGO;
 public bool DragWindow = false;
 public string levelToLoadWhenClickedPlay = "";
 public string[] AboutTextLines = new string[0];
 
 
 private string clicked = "", MessageDisplayOnAbout = "About \n ";
 private Rect WindowRect = new Rect((Screen.width / 2) - 100, Screen.height / 2, 200, 200);
 private float volume = 1.0f;
 
 private void Start()
 {
     for (int x = 0; x < AboutTextLines.Length;x++ )
     {
         MessageDisplayOnAbout += AboutTextLines[x] + " \n ";
     }
     MessageDisplayOnAbout += "Press Esc To Go Back";
 }
 
 private void OnGUI()
 {
     if (background != null)
         GUI.DrawTexture(new Rect(0,0,Screen.width , Screen.height),background);
     if (LOGO != null && clicked != "about")
         GUI.DrawTexture(new Rect((Screen.width / 2) - 100, 30, 200, 200), LOGO);
     
     GUI.skin = guiSkin;
     if (clicked == "")
     {
         WindowRect = GUI.Window(0, WindowRect, menuFunc, "Main Menu");
     }
     else if (clicked == "options")
     {
         WindowRect = GUI.Window(1, WindowRect, optionsFunc, "Options");
     }
     else if (clicked == "about")
     {
         GUI.Box(new Rect (0,0,Screen.width,Screen.height), MessageDisplayOnAbout);
     }else if (clicked == "resolution")
     {
         GUILayout.BeginVertical();
         for (int x = 0; x < Screen.resolutions.Length;x++ )
         {
             if (GUILayout.Button(Screen.resolutions[x].width + "X" + Screen.resolutions[x].height))
             {
                 Screen.SetResolution(Screen.resolutions[x].width,Screen.resolutions[x].height,true);
             }
         }
         GUILayout.EndVertical();
         GUILayout.BeginHorizontal();
         if (GUILayout.Button("Back"))
         {
             clicked = "options";
         }
         GUILayout.EndHorizontal();
     }
 }
 
 private void optionsFunc(int id)
 {
     if (GUILayout.Button("Resolution"))
     {
         clicked = "resolution";
     }
     GUILayout.Box("Volume");
     volume = GUILayout.HorizontalSlider(volume ,0.0f,1.0f);
     AudioListener.volume = volume;
     if (GUILayout.Button("Back"))
     {
         clicked = "";
     }
     if (DragWindow)
         GUI.DragWindow(new Rect (0,0,Screen.width,Screen.height));
 }
 
 private void menuFunc(int id)
 {
     //buttons 
     if (GUILayout.Button("Play Game"))
     {
         //play game is clicked
         Application.LoadLevel(1);
     }
     if (GUILayout.Button("Options"))
     {
         clicked = "options";
     }
     if (GUILayout.Button("About"))
     {
         clicked = "about";
     }
     if (GUILayout.Button("Quit Game"))
     {
         Application.Quit();
     }
     if (DragWindow)
         GUI.DragWindow(new Rect(0, 0, Screen.width, Screen.height));
 }
 
 private void Update()
 {
     if (clicked == "about" && Input.GetKey (KeyCode.Escape))
         clicked = "";
 }

}

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Hiding the cursor on a certain level. Pause Menu help. 2 Answers

Fast Question - Main menu / off camera 1 Answer

Trying to refer to my Scripts, not working...? 2 Answers

Script to start another object 2 Answers

Character Loading Location 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges