- Home /
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.
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!
Set your score to zero in the start function. On whatever script is keeping score.
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.
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.
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.
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
Follow this Question
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