• 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 /
  • Help Room /
avatar image
0
Question by lauren_davison · Dec 14, 2015 at 06:06 PM · menusceneslinking

How do you link scenes together?

Does anyone know how I go about linking a game menu scene to another scene which would be the game itself?

Comment
Add comment
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

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by robin-theilade · Dec 14, 2015 at 06:35 PM

@lauren_davison, assuming you're using the new Unity GUI for creating the game menu this is the way I would load another scene from game menu.

1) You will need a script that handles the game menu. Something like this:

 using UnityEngine;
 
 /// <summary>
 /// Handles interaction with the game menu.
 /// </summary>
 public class GameMenu : MonoBehaviour
 {
     /// <summary>
     /// The name of the scene that contains the actual game.
     /// </summary>
     public string gameSceneName;
 
     /// <summary>
     /// Loads the actual game scene.
     /// </summary>
     public void StartGame()
     {
         Application.LoadLevel(this.gameSceneName);
     }
 }

2) Add this script to a game object in the game menu scene and enter the name of the scene that contains the actual game in the "Game Scene Name" field.

3) On the button that starts the actual game in the menu, assign the game object containing the GameMenu behaviour as "On Click()" handler and selects it's StartGame() function.

4) Make sure that both the game menu and actual game scenes are added to the list of scenes in the "Build Settings" window.

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
0

Answer by G4merSylver · Dec 14, 2015 at 06:34 PM

SceneManager.LoadScene() or SceneManager.LoadScene

Create an button and attach an function with one of the upper, preferably the latter.

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
0

Answer by Jessespike · Dec 14, 2015 at 06:36 PM

You can write a script with functions that the UI will call.

 public class MainMenuCommands : MonoBehaviour {
 
     public void StartGame()
     {
         Application.LoadLevel("Game_Scene");
     }
 }

Then hook up the function to a button's OnClick Event.

ugui button onclick

The script doesn't have to be on the same GameObject, it's just here to show as an example.


button-onclick.jpg (17.9 kB)
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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How to keep overlay menu as I load different scenes. 0 Answers

Restart a Scene 1 Answer

Wiring Transform Channels Between a Source and a Target 2 Answers

How do you do a dropdown menu that changes resolution? 0 Answers

how to tell what scene the player was previously in 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges