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
0
Question by Michel1990 · Mar 18, 2014 at 04:26 PM · c#sceneloadlevelmainmenu

How to start a NEW scene in my main menu.

Heey there unity guys,

I want to start a new scene. When i start a game and quit the game i return back in my "Main Menu". There i can start a game Application.Loadlevel ("Level1");

When i go back to my "Level1" it seems i have the same scene i started the first time.

I dont want to go back to my old scene, but i want to begin a new scene.

So how can i create a new scene in this menu?

     void mainMenu()
     {
         if (GUI.Button(new Rect((screenWidth - buttonWidth) * 0.5f, screenHeight * 0.1f, buttonWidth, buttonHeight), "Start Game"))
         {
             Application.LoadLevel("Level 1");  
         }
 
         if (GUI.Button(new Rect((screenWidth - buttonWidth) * 0.5f, screenHeight * 0.5f, buttonWidth, buttonHeight), "Quit Game"))
         {
             Application.LoadLevel("Main Menu");
         }
     }

Thanks for helping.

Comment
Add comment · Show 4
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 Michel1990 · Mar 18, 2014 at 10:36 PM 0
Share

I am sorry for being not discrete. I am new to C# program$$anonymous$$g and Unity.

So lets start over again...

I have a game that starts with a main menu with the option to start the game. When i start the game i go to Level 1. In this game i count the gametime and i can get points with this game.

Then i can play Level 1 and i can quit my game using a pause menu. I have created a pause menu with the options to resume and quit.

When i press quit, unity goes back to the $$anonymous$$ain menu. And in the main menu i can choose to play the game again.

But when i go back to Level 1. i see that my points are still the same and my gametime is at zero.

Can anyone help me with this problem?

Thank you very much guys!

avatar image Dblfstr · Mar 18, 2014 at 11:48 PM 0
Share

Set your score to zero in the start function. On whatever script is keeping score.

avatar image Bluewell · Mar 19, 2014 at 11:18 AM 0
Share

I think by gametime you mean time.timescale. You may have some scripting problems for pause menu. You must have been used Time.timeScale = 0; to pause the game I guess. Set this in your Level 1 Start() function:

void Start() { Time.timeScale = 1; Score = 0; }

so the gametime will not be zerod out at the begining and points will be 0 at the begining of Level 1 as Dblfstr stated.

I still, highly insist that you shuold check if you have 2 seperate scenes named $$anonymous$$ain $$anonymous$$enu and Level 1 in your Assets folder, so everything will be O$$anonymous$$.

If the problem persists, please attach the script and a screenshot for us.

I hope it helped.

avatar image Dblfstr · Mar 19, 2014 at 03:25 PM 0
Share

I think he just wants to have the one scene "Level 1" be his game. So he can start the game from the main menu. The only problem, if I understand correctly, is that the score remains. Which, as I stated, is as simple as setting score = 0; in the start function of whatever script is keeping score. So, you can play the game, or "Level 1" as many times as you like, and always start at 0 for your score.

1 Reply

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

Answer by Bluewell · Mar 18, 2014 at 06:22 PM

I don't really understand the question.

If the problem is; When you press the "Start Game" button, Level 1 doesn't load from the begining (it continues from last camera point, last position etc.): then you need to create 2 specific scenes named Level 1 and Main Menu. Then this script should work.

If the problem is; When you are in Level 2 and you press "Quit Game" button, then in Main Menu you press "Start Game" button and it loads Level 1 but you wanted it to load Level 2: then you need to create a string flag to load them properly. You shuold have TheLevelFlag = Application.LoadedLevelName; in your script and for Start Game button: Application.LoadLevel(TheLevelFlag);

I hope this answers your question.

Comment
Add comment · Show 1 · 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 Dblfstr · Mar 18, 2014 at 07:23 PM 0
Share

Agree, it is hard to understand what is happening, and what you want to happen. The script above, only leaves two options. Load the Scene named "Level 1" and load the scene named "$$anonymous$$ain $$anonymous$$enu". If this script is in the main menu scene, it will reload the scene you are in when clicking Quit button. And, it will load "Level 1" when Start Game is pressed. If this script is in "Level 1" then Level 1 will be reloaded when you click Start Game, and "$$anonymous$$ain $$anonymous$$enu" will be loaded when you click quit.

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

23 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How clean the level before loading another one? 3 Answers

Scene Asset Bundle - LoadLevelAdditive and OnLevelWasLoaded 1 Answer

Application.LoadLevel Strange Problem 2 Answers

Can a script be loaded to a next scene? 3 Answers

Multiple Cars not working 1 Answer


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