Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

EditorSceneManager Open Scene from Build Index

Discussion in 'Scripting' started by liphttam1, Oct 11, 2018.

  1. liphttam1

    liphttam1

    Joined:
    Nov 11, 2014
    Posts:
    5
    Hey all,

    I'm trying to use EditorSceneManager.OpenScene but I want to use build index to determine the scene I open.

    I wanted to use EditorSceneManager.OpenScene(EditorSceneManager.GetSceneByBuildIndex(0).path) but this will return null, (I do have scenes in my build index btw)

    Is there any way I can use EditorSceneManager.OpenScene with build index?
     
  2. FernandoHC

    FernandoHC

    Joined:
    Feb 6, 2018
    Posts:
    251
    I'm a bit confused to why you're going through all that work when you can simply do SceneManager.LoadScene(0); replacing 0 with the scene build index.
    Or if it is an editor mode scene, do EditorSceneManager.LoadScene(0);

    Is that not what you want to do?
     
  3. liphttam1

    liphttam1

    Joined:
    Nov 11, 2014
    Posts:
    5
    SceneManager.LoadScene can only be used in play mode so it doesn't fit my use case.
     
  4. LurkingNinjaDev

    LurkingNinjaDev

    Joined:
    Jan 20, 2015
    Posts:
    829