Best Way To Return To Main Menu In This Situation...
I have my splash screen/title screen/main menus/pause screen in one scene that gets loaded first, and the level in another screen that's loaded when the player hits start. Besides the splash screen, everything from the first scene is DontDestroyOnLoad and becomes inactive. I have a quit button on the pause screen that originally just quit the game entirely, but I want to make it return to the main menu (i.e. destroy the level scene so the level would be loaded fresh when start was clicked again, and turn back on the main menu).
I am using 5.2 and was trying to use the new Application.UnloadLevel level function, but I keep getting an error that it is unsupported. Does anyone know how to get that function to work, or what would be an actual way to accomplish my goal here?
Answer by frost4285 · Sep 24, 2015 at 04:20 PM
@jprecise Well you could try to just use Application.LoadLevel to load your Menu Scene. It will destroy everything that is not DontDestroyOnLoad . But if you don't check if object already exists (singleton pattern) you probably will get copies of objects which are DontDestroyOnLoad.
You only can unload levels that was loaded additively (Application.LoadLevelAdditive or Application.LoadLevelAdditiveAsync)
So in it seems reasonable to load another scene (where level is) by some of those functions. And you wont need DontDestroyOnLoad on every object in the first scene
Your answer
Follow this Question
Related Questions
Some scripts seem to be breaking when re-loading a scene 0 Answers
Puzzled by delayed action effect on changes to appended script...? 0 Answers
Dynamic Menu creation 2 Answers
cant get a target menu open JRPG 1 Answer
Menu Problem 1 Answer