Created
April 15, 2023 09:42
-
-
Save irfanbaysal/87c9063f157f4a3942a85c09ac2a19da to your computer and use it in GitHub Desktop.
Play Mode Scene
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class StartSceneWindow : EditorWindow | |
{ | |
private const string ScenePath = "Assets/Core/Scenes/MainScene.unity"; | |
private void OnGUI() | |
{ | |
EditorSceneManager.playModeStartScene = (SceneAsset)EditorGUILayout.ObjectField(new GUIContent("Start Scene"), | |
EditorSceneManager.playModeStartScene, typeof(SceneAsset),false); | |
if (GUILayout.Button("Set as Start Scene")) | |
SetPlayModeStartScene(ScenePath); | |
} | |
private void OnInspectorUpdate() | |
{ | |
SetPlayModeStartScene(ScenePath); | |
} | |
private static void SetPlayModeStartScene(string scenePath) | |
{ | |
var desiredScene = AssetDatabase.LoadAssetAtPath<SceneAsset>(scenePath); | |
if (desiredScene == null) | |
Debug.Log("Could not find Scene " + scenePath); | |
else | |
EditorSceneManager.playModeStartScene = desiredScene; | |
} | |
[MenuItem("Baysz /Settings")] | |
private static void StartScene() | |
{ | |
GetWindow<StartSceneWindow>(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment