Search Unity

How to Always Run Loading Scene when I hit the Play button

Discussion in 'Editor & General Support' started by ohthepain, Aug 31, 2019.

  1. ohthepain

    ohthepain

    Joined:
    May 31, 2017
    Posts:
    100
    Is there a way to get Unity to run my loading scene when I hit run, as opposed to the scene that I am currently editing?

    My home scene won't run unless the loading scene has been run first. So every time I run I have to open the loading scene. Then when I am finished I have to load the scene I am working on again. It's a lot of navigation.
     
  2. ibbybn

    ibbybn

    Joined:
    Jan 6, 2017
    Posts:
    193
    Code (CSharp):
    1.     [MenuItem ("Edit/Play from Prelaunch Scene %l")]
    2.     public static void PlayFromPrelaunchScene () {
    3.         if (EditorApplication.isPlaying == true) {
    4.             EditorApplication.isPlaying = false;
    5.             return;
    6.         }
    7.  
    8.         EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo ();
    9.         EditorSceneManager.OpenScene ("Assets/YourStartLevel.unity");
    10.         EditorApplication.isPlaying = true;
    11.     }
    Put this in a script. Then you can assign a shortcut in the unity shortcuts menu ( search for prelaunch ).
     
  3. ohthepain

    ohthepain

    Joined:
    May 31, 2017
    Posts:
    100

    Thanks for the script! It's not quite what I am looking for as I am hoping to get back to what I was editing before launching.

    To edit a dialog I actually have to drag the prefab into a scene and navigate to what I want to edit. I am trying to not have to repeat that process every time I run. It wastes a ton of time.