- Home /
Load scene in editor playmode synchronously
Main Question
I'm trying to load a scene in the editor while in playmode and get the exact behaviour of:
SceneManager.LoadScene(ScenePath, LoadSceneMode.Single);
Except without requiring the scene to be in the build settings.
I would have expected this to work:
EditorSceneManager.LoadSceneInPlayMode(ScenePath, new UnityEngine.SceneManagement.LoadSceneParameters(LoadSceneMode.Single));
However the scene appears to load asynchronously, which I don't want for my particular use case.
Is there a way to acomplish what I'm looking for here?
Additional details (my use case and "why" I want this)
What I'm doing is creating a loader for scene sets that will additively load a bunch of scenes with different constraints on their loading behaviour (such as: load async, always reload when transitioning same->same, and other features). I have this working fine in the editor while I'm not in play mode, I have it working fine in a built player, but the last case is getting this to work while in the editor and in play mode.
The reason I need "single" loading at all is when you transition from one scene set to another and they share no common scenes. Since I can't unload every scene, I'm just skipping the unload step all together and having the first synchronously loading scene load with LoadSceneMode.Single to cause everything else to unload.
On the off chance it's relevant (I really hope not) I'm trying to do this from inside a custom editor's OnInspectorGUI call. I'm triggering it from a button press in there.
Options I'm aware of:
EditorSceneManager.OpenScene with OpenSceneMode.Single
problem: Does not work in play mode
EditorSceneManager.LoadSceneInPlayMode with LoadSceneParameters(LoadSceneMode.Single)
-problem: Scene is not loaded synchronously
SceneManager.LoadScene with LoadSceneMode.Single
-problem: Scene is required to be in the build settings
EditorSceneManager.LoadScene with LoadSceneMode.Single
problem: Scene is required to be in the build settings
Answer by JaredThomson · Feb 10, 2021 at 06:04 AM
Turns out I had a misunderstanding of what SceneManager.LoadScene(ScenePath, LoadSceneMode.Single); would even do.
A friend had pointed out the docs clearly state the load will happen within 1 frame, not actually at the call-site.
If you're facing a similar issue there are a few options. You could load async and subscribe to that callback to perform activation them. Another option is to subscribe to SceneManager.sceneLoaded and perform activation there.
Your answer
![](https://koobas.hobune.stream/wayback/20220613024749im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How Do I Link Different Scenes? 4 Answers
Change Scene keeping Character and GUI Canvas 1 Answer
Can't find game object / script after scene re-enter 1 Answer
Scene Loading Issue. 0 Answers
Unity Scene loading problem (slow loading until it freezes) 0 Answers