- Home /
2D main menu as a different scene - pausing and resuming
I am wondering how to go about this.
What I have is:
- When I press the PLAY button it starts playing the game.
- When I press ESCAPE on my keyboard it sets Time.timeScale to 0 and then loads the main menu scene.
What I want is:
- Load a 2D main menu scene when pressing escape and pause the current scene.
- When clicking on "resume" in the main menu it would continue the game.
My issue is.. how do I continue the game? I have tried simply setting Time.timeScale to 1 under Start()
but that just makes the game start from the beginning again.
I would like to do it this way because that'll separate the game itself from the main menu and I find it much more overviewable instead of having everything in one scene.
You'll have to save information on where everything was last at and load that again when you change back to the game scene.
I would suggest using just one scene.
Ins$$anonymous$$d of changing the time scale set up a state machine(google it). Then when its in the game state have only your game code run. If its in the menu state only have the menu code run.
Load a level for pause is not a good idea... What you should do if you do not know how is, make some gui and render it when needed using a bool.
It makes more sense to me to keep things separated but okay if that's how it works.
Your answer
Follow this Question
Related Questions
Best practice for countdown timer on game resume 1 Answer
Can't set Time.timeScale back to 1. 2 Answers
Pause, Unpause 1 Answer
Main menu button loads main menu level but it is Frozen!!! 0 Answers
How do I pause my game? 24 Answers