Рет қаралды 10
This video is about a script that provides quality of life and allows you start the game from any scene you please.
If you decide to name the script the same as mine you can copy paste this whole script, or else just change the name.
using UnityEditor;
using UnityEditor.SceneManagement;
[InitializeOnLoad]
public static class StartupSceneLoader
{
static StartupSceneLoader()
{
EditorApplication.playModeStateChanged += LoadStartupScene;
}
private static void LoadStartupScene(PlayModeStateChange state)
{
if(state == PlayModeStateChange.ExitingEditMode)
{
EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo();
}
if(state == PlayModeStateChange.EnteredPlayMode)
{
if(EditorSceneManager.GetActiveScene().buildIndex != 0)
{
EditorSceneManager.LoadScene(0);
}
}
}
}