0.7.2: Added asset bundle and addressable scenes to scene picker
This commit is contained in:
parent
9ba22f779d
commit
ca34993eb3
|
|
@ -1,7 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "Module.NavigationTool.Editor",
|
"name": "Module.NavigationTool.Editor",
|
||||||
"rootNamespace": "",
|
"rootNamespace": "Module.NavigationTool.Editor",
|
||||||
"references": [],
|
"references": [
|
||||||
|
"GUID:69448af7b92c7f342b298e06a37122aa"
|
||||||
|
],
|
||||||
"includePlatforms": [
|
"includePlatforms": [
|
||||||
"Editor"
|
"Editor"
|
||||||
],
|
],
|
||||||
|
|
@ -9,7 +11,7 @@
|
||||||
"allowUnsafeCode": false,
|
"allowUnsafeCode": false,
|
||||||
"overrideReferences": false,
|
"overrideReferences": false,
|
||||||
"precompiledReferences": [],
|
"precompiledReferences": [],
|
||||||
"autoReferenced": true,
|
"autoReferenced": false,
|
||||||
"defineConstraints": [],
|
"defineConstraints": [],
|
||||||
"versionDefines": [],
|
"versionDefines": [],
|
||||||
"noEngineReferences": false
|
"noEngineReferences": false
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
|
using UnityEditor.AddressableAssets;
|
||||||
|
using UnityEditor.AddressableAssets.Settings;
|
||||||
using UnityEditor.SceneManagement;
|
using UnityEditor.SceneManagement;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
|
|
@ -25,38 +27,13 @@ namespace Module.NavigationTool.Editor.Tools
|
||||||
return;
|
return;
|
||||||
|
|
||||||
EditorBuildSettingsScene[] scenes = EditorBuildSettings.scenes;
|
EditorBuildSettingsScene[] scenes = EditorBuildSettings.scenes;
|
||||||
var listNames = new List<string>(scenes.Length);
|
var listNames = new List<string>();
|
||||||
var listPaths = new List<string>(scenes.Length);
|
var listPaths = new List<string>();
|
||||||
|
|
||||||
for (var i = 0; i < scenes.Length; i++)
|
InitializeBuildSettingsScenes(listNames, listPaths);
|
||||||
{
|
InitializeAssetBundleScenes(listNames, listPaths);
|
||||||
if (string.IsNullOrEmpty(scenes[i].path))
|
InitializeAddressableScenes(listNames, listPaths);
|
||||||
continue;
|
InitializeRemainingScenes(listNames, listPaths);
|
||||||
|
|
||||||
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<SceneAsset>(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();
|
OPTIONS = listNames.ToArray();
|
||||||
PATHS = listPaths.ToArray();
|
PATHS = listPaths.ToArray();
|
||||||
|
|
@ -65,6 +42,104 @@ namespace Module.NavigationTool.Editor.Tools
|
||||||
SELECTED_INDEX = listPaths.IndexOf(activeScene.path);
|
SELECTED_INDEX = listPaths.IndexOf(activeScene.path);
|
||||||
IS_DIRTY = false;
|
IS_DIRTY = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void InitializeBuildSettingsScenes(List<string> listNames, List<string> listPaths)
|
||||||
|
{
|
||||||
|
EditorBuildSettingsScene[] scenes = EditorBuildSettings.scenes;
|
||||||
|
|
||||||
|
for (var i = 0; i < scenes.Length; i++)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(scenes[i].path))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
listNames.Add($"{Path.GetFileNameWithoutExtension(scenes[i].path)} \tBuild settings");
|
||||||
|
listPaths.Add(scenes[i].path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void InitializeAssetBundleScenes(List<string> listNames, List<string> listPaths)
|
||||||
|
{
|
||||||
|
string[] bundleNames = AssetDatabase.GetAllAssetBundleNames();
|
||||||
|
int startIndex = listNames.Count;
|
||||||
|
|
||||||
|
for (var i = 0; i < bundleNames.Length; i++)
|
||||||
|
{
|
||||||
|
string[] assetPaths = AssetDatabase.GetAssetPathsFromAssetBundle(bundleNames[i]);
|
||||||
|
|
||||||
|
for (var j = 0; j < assetPaths.Length; j++)
|
||||||
|
{
|
||||||
|
string path = assetPaths[j];
|
||||||
|
|
||||||
|
if (listPaths.Contains(path))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var scene = AssetDatabase.LoadAssetAtPath<SceneAsset>(path);
|
||||||
|
|
||||||
|
if (scene == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
listNames.Add($"{Path.GetFileNameWithoutExtension(path)} \tAsset bundle");
|
||||||
|
listPaths.Add(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (startIndex >= listNames.Count)
|
||||||
|
return;
|
||||||
|
|
||||||
|
listNames.Insert(startIndex, string.Empty);
|
||||||
|
listPaths.Insert(startIndex, string.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void InitializeAddressableScenes(List<string> listNames, List<string> listPaths)
|
||||||
|
{
|
||||||
|
var assets = new List<AddressableAssetEntry>();
|
||||||
|
AddressableAssetSettingsDefaultObject.Settings.GetAllAssets(assets, false);
|
||||||
|
int startIndex = listNames.Count;
|
||||||
|
|
||||||
|
for (var i = 0; i < assets.Count; i++)
|
||||||
|
{
|
||||||
|
if (!(assets[i].MainAsset is SceneAsset))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
string path = assets[i].AssetPath;
|
||||||
|
listNames.Add($"{Path.GetFileNameWithoutExtension(path)} \tAddressable");
|
||||||
|
listPaths.Add(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (startIndex >= listNames.Count)
|
||||||
|
return;
|
||||||
|
|
||||||
|
listNames.Insert(startIndex, string.Empty);
|
||||||
|
listPaths.Insert(startIndex, string.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void InitializeRemainingScenes(List<string> listNames, List<string> listPaths)
|
||||||
|
{
|
||||||
|
string[] guids = AssetDatabase.FindAssets("t:scene");
|
||||||
|
int startIndex = listNames.Count;
|
||||||
|
|
||||||
|
for (var i = 0; i < guids.Length; i++)
|
||||||
|
{
|
||||||
|
string path = AssetDatabase.GUIDToAssetPath(guids[i]);
|
||||||
|
|
||||||
|
if (listPaths.Contains(path))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var scene = AssetDatabase.LoadAssetAtPath<SceneAsset>(path);
|
||||||
|
|
||||||
|
if (scene == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
listNames.Add(path.Substring(7, path.Length - 13).Replace('/', '\\'));
|
||||||
|
listPaths.Add(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (startIndex >= listNames.Count)
|
||||||
|
return;
|
||||||
|
|
||||||
|
listNames.Insert(startIndex, string.Empty);
|
||||||
|
listPaths.Insert(startIndex, string.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,14 @@
|
||||||
{
|
{
|
||||||
"name": "com.module.navigationtool",
|
"name": "com.module.navigationtool",
|
||||||
"version": "0.7.1",
|
"version": "0.7.2",
|
||||||
"displayName": "Module.NavigationTool",
|
"displayName": "Module.NavigationTool",
|
||||||
"description": "Support for navigation tools, like favorites, history and toolbars",
|
"description": "Support for navigation tools, like favorites, history and toolbars",
|
||||||
"unity": "2019.2",
|
"unity": "2019.2",
|
||||||
"unityRelease": "17f1",
|
"unityRelease": "17f1",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
},
|
"com.unity.addressables": "1.10.0"
|
||||||
"keywords": [
|
},
|
||||||
|
"keywords": [
|
||||||
"navigation",
|
"navigation",
|
||||||
"favorites",
|
"favorites",
|
||||||
"history",
|
"history",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue