Last active
February 23, 2022 16:51
-
-
Save KenneyNL/cc9a96e3db2fdf4c36db59999259a924 to your computer and use it in GitHub Desktop.
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
using UnityEngine; | |
using UnityEditor; | |
using UnityEditor.SceneManagement; | |
using System.Collections.Generic; | |
using System.IO; | |
// Scene selection | |
class sceneWindow : EditorWindow { | |
[MenuItem ("Window/Scenes")] | |
public static void ShowWindow () { | |
EditorWindow.GetWindow(typeof(sceneWindow), false, "Scenes"); | |
} | |
int selected; int changedSelected; | |
List<string> scenes = new List<string>(); | |
void OnGUI () { | |
EditorGUILayout.Space(); | |
scenes.Clear(); | |
string[] dropOptions = new string[EditorBuildSettings.scenes.Length]; | |
for(int i = 0; i < EditorBuildSettings.scenes.Length; i++){ | |
EditorBuildSettingsScene scene = EditorBuildSettings.scenes[i]; | |
string sceneName = Path.GetFileNameWithoutExtension(scene.path); | |
scenes.Add(sceneName); | |
dropOptions[i] = scenes[i]; | |
if(scene.path == EditorSceneManager.GetActiveScene().path){ | |
selected = changedSelected = i; | |
} | |
} | |
// Selection | |
changedSelected = EditorGUILayout.Popup(selected, dropOptions); | |
if(selected != changedSelected){ | |
selected = changedSelected; | |
EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo(); | |
EditorSceneManager.OpenScene(EditorBuildSettings.scenes[changedSelected].path); | |
} | |
EditorGUILayout.Space(); | |
EditorGUILayout.LabelField("Scenes", EditorStyles.boldLabel); | |
for(int i = 0; i < scenes.Count; i++){ | |
if(GUILayout.Button(scenes[i], GUILayout.Height(20))){ | |
selected = changedSelected = i; | |
EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo(); | |
EditorSceneManager.OpenScene(EditorBuildSettings.scenes[i].path); | |
} | |
dropOptions[i] = scenes[i]; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment