- Home /
Scene loading problem
Hi, I'm creating a mobile game. I've currently three scenes:
Main menu
Level 1
Level 2
And a script which load a level when the player press a button. When I load the scene for the first time everything is ok BUT, if I came back to the main menu and select another level, the main character and the enemies doesn't move until I use the pause button and the resume button.
This strange problem does not appear if I reload the current scene. It appears only if I make the following actions sequence
Main menu -> level (1 or 2) Level -> main menu Main menu -> level (doesn't matter which one of the two)
To load the scene I use SceneManager.LoadScene()
Answer by FrancescoDiTommasoSWCG · Apr 04, 2018 at 03:32 PM
Solved. The problem was that when I pause the game I set the time to 0. Then, if I come back to menu the time is still 0. It changes if iI press again pause and then resume which put the time to 1.
Thanks guy, I had the same problem and wondered where it comes from XD
Answer by davidcox70 · Apr 04, 2018 at 02:41 PM
Have you used "DontDestroyOnLoad" anywhere? Loadscene should reset everything to how you have the scenes in the editor. But "DontDestroyOnLoad" can be used to maintain data across scene loading. Maybe you have some parameters in there that need to be reset by script as you change scenes?
Answer by tormentoarmagedoom · Apr 04, 2018 at 02:44 PM
The problem then is not the loading scene itself. When a scene is load, Unity destroys all the object of the scene, then instantiate al objects of the new scene (exept for that objects with "DontDestroyOnLoad" property).
Are you using the DontDestroyOnLoad somewhere?.
When you say press de paise button you mean the Unity pause button at the top of the script? You should debug ypur code and see whats the satate of all scripts and variables.
Post what you find
Answer by FlaSh-G · Apr 04, 2018 at 02:22 PM
This is a problem with the implementation of your pause button - not with the scene loading itself. Mind posting the pause button's pausing code?
Ok I got the problem. Thank you, your comment helped me ;)
I convert the comment into answer. Please accet it as correct for future users.
Thanks! :D
Answer by Dracmarz · Mar 25, 2021 at 12:25 PM
I just wanted to give my experience with this as well in case others stumble upon this thread (This is a highly suggested thread on Google based on the search criteria).
In my case when I was returning to the "Menu" scene from "Level1" I found two entries for the Menu scene in the "Hierarchy" window. One Menu scene is loaded and active, and there is a second one stuck on status "is loading". When trying to open more scenes they will end up having stats "is loading" as well.
I fixed it by finding the duplicate "Menu Scene Loader" in the Level scene and removing it.
Hopefully this helps someone.
Omg I have the exact same problem as you but can’t for the life of me understand what’s making this happen as my game over scene is a scene and is only referenced when players health is on zero....
Your answer
Follow this Question
Related Questions
Attempting to Create an Essential SceneElements Checker 0 Answers
UnloadSceneAsync() does not seem to work with additive scenes. 1 Answer
How can I make a loading screen with LoadSceneAsync 2 Answers
Old scene still appears for short time when switching scene 0 Answers
Multiple scenes loads to multiple clients and server can have a parallel view of each client scene ? 1 Answer