# Load scene without being in build settings and without using AssetBundle

This is the closest I've gotten:

    EditorSceneManager.OpenScene(
AssetDatabase.GUIDToAssetPath(
AssetDatabase.FindAssets(
new string[] { "Assets" }
)[0]
)
);


However this generates an error at runtime:

InvalidOperationException: This cannot be used during play mode, please use SceneManager.LoadScene()/SceneManager.LoadSceneAsync() instead.


I can't follow its suggestion because those functions require the scene to be in build settings or an asset bundle. So, is there any other option?

I wonder how (and if) Addressables achieve this? Note: I'm not willing to switch to Addressables - I'm quite enjoying working with AssetBundles.

Why?

My game uses AssetBundles for general loading of EVERYTHING, so there's only one blank scene in build settings. However, during development I'd rather not have to continuously build and load from AssetBundles, so I'm trying to dynamically load scenes WITHOUT having to add them to build settings.

Unfortunately, the only ways to load scenes are the two options you already mentioned. However, just because it’s in the list of scenes, doesn’t mean it needs to end up in the built game. There are two options here.

The first option is to manually uncheck the checkboxes in the build settings next to all of the scenes that you don’t want to include whenever you do a build. Simply click on scene 1, then shift-click on the last scene, and toggle any of the checkboxes.

The alternative is to write a small script which automatically modifies the build settings whenever you do a build. This shouldn’t be too difficult, but if you are not doing a lot of builds it may not be worth the effort.

• I'm not sure how to have a script run when I do a build (and after the build completes to undo the action). Do you know how to achieve those? – Bilal Akil Sep 17 '19 at 3:41
• Actually that's not too hard, with I(Pre|Post)processBuildWithReport. Thanks! – Bilal Akil Sep 17 '19 at 4:09
• Turns out there's a (maybe new) method doing exactly what I need! See my answer – Bilal Akil Sep 17 '19 at 6:04

Turns out there's EditorSceneManager.LoadSceneInPlayMode which does exactly what I'm looking for! Awesome.