Search Unity

EditorSceneManager.OpenScene not working for SceneBundles?

Discussion in 'Asset Bundles' started by roomera, Nov 7, 2019.

  1. roomera

    roomera

    Joined:
    Sep 27, 2016
    Posts:
    17
    Does the EditorSceneManager support opening scenes from AssetBundles during Edit mode? I wasn't able to find any specific mentions of this in the documentation.

    For example, the code below works in executed in play mode, but throws "ArgumentException: Scene file not found." in Edit mode.

    I would appreciate any guidance on this! Thanks in advance.

    Code (CSharp):
    1. public class TestClass : MonoBehaviour {
    2.     [MenuItem("Menu/Load Scene")]
    3.     private static void LoadScene() {
    4.         AssetBundle bundle = AssetBundle.LoadFromFile("Bundles/samplescene");
    5.    
    6.         string path = bundle.GetAllScenePaths()[0];
    7.         Debug.Log($"Opening {path}");
    8.         if (Application.isPlaying) {
    9.             // This works!
    10.             SceneManager.LoadScene(path);
    11.         } else {
    12.             // This does not. It throws a "scene not found" error
    13.             EditorSceneManager.OpenScene(path);
    14.         }
    15.     }
    16. }
     
    Last edited: Nov 7, 2019
    amcakebread likes this.
  2. amcakebread

    amcakebread

    Joined:
    Nov 8, 2016
    Posts:
    24
    did you ever find a solution to this - I need to do exactly the same thing and I am having exactly the same problem
     
unityunity