From 17c55cd03c5958f146430b8ee8e744651031c0c3 Mon Sep 17 00:00:00 2001 From: Anders Ejlersen Date: Tue, 27 Apr 2021 15:14:12 +0200 Subject: [PATCH] 0.6.2: Added all scenes to scene picker --- Editor/Toolbar/Tools/ToolScenePicker.cs | 36 +++++++++++++++++++++---- package.json | 2 +- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/Editor/Toolbar/Tools/ToolScenePicker.cs b/Editor/Toolbar/Tools/ToolScenePicker.cs index 023477c..eeb6258 100644 --- a/Editor/Toolbar/Tools/ToolScenePicker.cs +++ b/Editor/Toolbar/Tools/ToolScenePicker.cs @@ -29,15 +29,36 @@ namespace Game.NavigationTool.Editor.Tools EditorBuildSettingsScene[] scenes = EditorBuildSettings.scenes; var listNames = new List(scenes.Length); var listPaths = new List(scenes.Length); - + for (var i = 0; i < scenes.Length; i++) { if (string.IsNullOrEmpty(scenes[i].path)) continue; - listNames.Add(Path.GetFileNameWithoutExtension(scenes[i].path)); + listNames.Add($"{Path.GetFileNameWithoutExtension(scenes[i].path)} (Build Settings)"); listPaths.Add(scenes[i].path); } + + string[] guids = AssetDatabase.FindAssets("t:scene"); + int startIndex = listNames.Count; + + for (var i = 0; i < guids.Length; i++) + { + string path = AssetDatabase.GUIDToAssetPath(guids[i]); + var scene = AssetDatabase.LoadAssetAtPath(path); + + if (scene == null || listPaths.Contains(path)) + continue; + + listNames.Add(path.Substring(7, path.Length - 13).Replace('/', '\\')); + listPaths.Add(path); + } + + if (startIndex < listNames.Count) + { + listNames.Insert(startIndex, string.Empty); + listPaths.Insert(startIndex, string.Empty); + } OPTIONS = listNames.ToArray(); PATHS = listPaths.ToArray(); @@ -56,14 +77,19 @@ namespace Game.NavigationTool.Editor.Tools { Initialize(); int temp = EditorGUI.Popup(rect, SELECTED_INDEX, OPTIONS, styles.popup); - - if (temp != -1 && temp != SELECTED_INDEX && OPTIONS.Length != 0) + + if (temp > -1 && temp != SELECTED_INDEX && OPTIONS.Length != 0) { + string path = PATHS[temp]; + + if (string.IsNullOrEmpty(path)) + return; + SELECTED_INDEX = temp; EditorSceneManager.OpenScene(PATHS[SELECTED_INDEX], OpenSceneMode.Single); } } - + public float CalculateWidth() { return 100.0f; diff --git a/package.json b/package.json index 33758fa..b157187 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.module.navigationtool", - "version": "0.6.1", + "version": "0.6.2", "displayName": "Module.NavigationTool", "description": "Support for navigation tools, like favorites, history and toolbars", "unity": "2019.2",