Last active
March 8, 2017 20:10
-
-
Save BrodyB/179b27078d94d8a504816e7222d32459 to your computer and use it in GitHub Desktop.
Adds a window for Unity that lets you easily switch to scenes in your build settings
This file contains hidden or 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; | |
public class SceneSwitchWindow : EditorWindow | |
{ | |
[MenuItem("Window/Scene Switch Window")] | |
public static void ShowWindow () | |
{ | |
SceneSwitchWindow win = (SceneSwitchWindow)EditorWindow.GetWindow(typeof(SceneSwitchWindow)); | |
win.titleContent.text = "Scene Switch"; | |
} | |
void OnGUI () | |
{ | |
int sceneCount = EditorBuildSettings.scenes.Length; | |
for (int i = 0; i < sceneCount; i++) | |
{ | |
if (!EditorBuildSettings.scenes[i].enabled) | |
GUI.enabled = false; | |
EditorGUILayout.BeginHorizontal(); | |
string sceneName = System.IO.Path.GetFileNameWithoutExtension(EditorBuildSettings.scenes[i].path); | |
if (GUILayout.Button(sceneName)) | |
{ | |
EditorSceneManager.OpenScene(EditorBuildSettings.scenes[i].path); | |
} | |
if (GUILayout.Button("+", GUILayout.Width(32f))) | |
{ | |
EditorSceneManager.OpenScene(EditorBuildSettings.scenes[i].path, OpenSceneMode.Additive); | |
} | |
EditorGUILayout.EndHorizontal(); | |
GUI.enabled = true; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment