Executing first scene in build settings when pressing play button in editor?

Hi!,

Is there anyway to execute first scene that has been specified in build settings (the first scene game will load when in production) when I press play button (or whatever short-cut) in unity editor?.

The problem is that I have an startup scene that inits everything before entering the first real scene. This startup scene creates some objects that will live all game and it is a bit of a pain to:

  1. Save current editing scene

  2. Find startup scene

  3. Load startup scene

  4. Press play

  5. Get to the scene I was editing

This has to be done for every little change I do in a scene in the game. I know steps 4 and 5 can’t be avoid obviously, but what about from 1 to 3. Is there anyway to let unity run scenes in the order they appear in the building settings when executing in editor?.

Thanks in advance.

Put this code in menu item (Unity - Scripting API: MenuItem). Rough code:

EditorPrefs.SetString("lastScene", EditorApplication.currentScene);
EditorApplication.SaveScene();
EditorApplication.LoadScene(EditorBuildSettings.scenes[0]);
EditorApplication.Play();

When play is finished, do this. I’m not entirely sure how to do “When play is finished” part :slight_smile: Maybe put it on another menu item? :slight_smile:

EditorApplication.LoadScene(EditorPrefs.GetString("lastScene"));

Assuming you don’t need to switch back and forth between projects, a simple way to do this is:

File–>Scene Autoload–>Load Master On Play

File–>Scene Autoload–>Select Master Scene (pick the Scene file you always want to jump to when hitting Play).