1.3.1: Removing all package scenes from ScenePicker, due to read-only scenes not being loadable

This commit is contained in:
Anders Ejlersen 2022-01-21 21:55:57 +01:00
parent c54a325cfe
commit 21cd509506
3 changed files with 27 additions and 14 deletions

View file

@ -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<SceneAsset>(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);
}
}

View file

@ -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"));
}
}
}

View file

@ -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",