diff --git a/Editor/Toolbar/Tools/ToolScenePicker.cs b/Editor/Toolbar/Tools/ToolScenePicker.cs index 38bd0f0..36a03e4 100644 --- a/Editor/Toolbar/Tools/ToolScenePicker.cs +++ b/Editor/Toolbar/Tools/ToolScenePicker.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.IO; using JetBrains.Annotations; using UnityEditor; @@ -65,13 +66,18 @@ namespace Module.NavigationTool.Editor.Toolbar if (listPaths.Contains(path)) continue; + if (!path.StartsWith("Assets")) + continue; var scene = AssetDatabase.LoadAssetAtPath(path); if (scene == null) continue; - - listNames.Add(path.Substring(7, path.Length - 13).Replace('/', '\\')); + + string sceneName = path.Substring(7, path.Length - 13) + .Replace('/', '\\'); + + listNames.Add(sceneName); listPaths.Add(path); } @@ -91,16 +97,22 @@ namespace Module.NavigationTool.Editor.Toolbar { Initialize(); int temp = EditorGUI.Popup(rect, SELECTED_INDEX, OPTIONS, styles.popup); - - 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); + if (temp <= -1 || temp == SELECTED_INDEX || OPTIONS.Length == 0) + return; + if (string.IsNullOrEmpty(PATHS[temp])) + return; + + try + { + Scene scene = EditorSceneManager.OpenScene(PATHS[temp], OpenSceneMode.Single); + + if (scene.isLoaded) + SELECTED_INDEX = temp; + } + catch (Exception e) + { + Debug.LogWarningFormat("Failed to load scene ({0}), due to exception: {1}", PATHS[temp], e.Message); } } diff --git a/Editor/Toolbar/Tools/ToolScenePickerPostProcess.cs b/Editor/Toolbar/Tools/ToolScenePickerPostProcess.cs index 041319f..9d9d30a 100644 --- a/Editor/Toolbar/Tools/ToolScenePickerPostProcess.cs +++ b/Editor/Toolbar/Tools/ToolScenePickerPostProcess.cs @@ -13,7 +13,8 @@ namespace Module.NavigationTool.Editor.Toolbar private static bool HasChange(string[] assets) { - return assets.Any(s => s.EndsWith(".unity")) || assets.Any(s => s.EndsWith("EditorBuildSettings.asset")); + return assets.Any(s => s.EndsWith(".unity")) || + assets.Any(s => s.EndsWith("EditorBuildSettings.asset")); } } } \ No newline at end of file diff --git a/package.json b/package.json index f31f1a9..0d3e84b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.module.navigationtool", - "version": "1.3.0", + "version": "1.3.1", "displayName": "Module.NavigationTool", "description": "Support for navigation tools, like favorites, history and toolbars", "unity": "2019.2",