using UnityEngine; using UnityEditor; using UnityEditor.SceneManagement; using System.Collections.Generic; using System.IO; using System.Linq; static class QuickSceneWindowHelper { const float WindowWidth = 250f; const float WindowHeight = 300f; public static void ShowCentered(string title) where T : EditorWindow { var window = EditorWindow.GetWindow(title); var mainWindow = EditorGUIUtility.GetMainWindowPosition(); window.position = new Rect( (mainWindow.width - WindowWidth) / 2, (mainWindow.height - WindowHeight) / 2, WindowWidth, WindowHeight); window.Show(); } public static IEnumerable GetAvailableScenes() { string currentScenePath = EditorSceneManager.GetActiveScene().path; return EditorBuildSettings.scenes.Where(scene => !string.Equals(scene.path, currentScenePath, System.StringComparison.OrdinalIgnoreCase)); } public static string GetSceneDisplayName(EditorBuildSettingsScene scene) { string sceneName = Path.GetFileNameWithoutExtension(scene.path); return scene.enabled ? sceneName : $"{sceneName} (not in build)"; } public static void DrawSceneList(OpenSceneMode mode) { EditorGUILayout.LabelField("Available Scenes:", EditorStyles.boldLabel); EditorGUILayout.Space(); var scenes = EditorBuildSettings.scenes; if (scenes.Length == 0) { EditorGUILayout.HelpBox("No Scenes in Build Settings", MessageType.Warning); return; } var availableScenes = GetAvailableScenes().ToList(); if (availableScenes.Count == 0) { EditorGUILayout.HelpBox("No other scenes available", MessageType.Info); return; } foreach (var scene in availableScenes) { if (GUILayout.Button(GetSceneDisplayName(scene), GUILayout.Height(30))) { OpenScene(scene.path, mode); } } } public static void OpenScene(string path, OpenSceneMode mode) { if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo()) return; EditorSceneManager.OpenScene(path, mode); Debug.Log($"Opened scene ({mode}): {path}"); EditorWindow.focusedWindow?.Close(); } } public class QuickSceneWindow : EditorWindow { [MenuItem("GameObject/Quick Open Adaptive Scene", false, 1)] public static void ShowWindow() => QuickSceneWindowHelper.ShowCentered("Quick Scene"); void OnGUI() => QuickSceneWindowHelper.DrawSceneList(OpenSceneMode.Additive); } public class QuickSingleSceneWindow : EditorWindow { [MenuItem("GameObject/Quick Open Single Scene", false, 2)] public static void ShowWindow() => QuickSceneWindowHelper.ShowCentered("Quick Single Scene"); void OnGUI() => QuickSceneWindowHelper.DrawSceneList(OpenSceneMode.Single); }