From ae4dc56e84ee4478b9eda99ee0b2e8968b7c9f0b Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Mon, 16 Dec 2019 20:54:55 -0500 Subject: [PATCH] Use all assetbundles instead of only last --- Dissonance/Inspector/AssetInspector.cs | 45 ++++++++++++++------------ 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/Dissonance/Inspector/AssetInspector.cs b/Dissonance/Inspector/AssetInspector.cs index 0bad368..3655860 100644 --- a/Dissonance/Inspector/AssetInspector.cs +++ b/Dissonance/Inspector/AssetInspector.cs @@ -9,19 +9,18 @@ namespace Dissonance.Inspector { public static class AssetInspector { - private static AssetBundle bundle; + private static AssetBundle[] allBundles; public static bool Init() { - foreach(AssetBundle ab in AssetBundle.GetAllLoadedAssetBundles()) + allBundles = AssetBundle.GetAllLoadedAssetBundles().ToArray(); + string[] allBundleNames = new string[allBundles.Length]; + for (int i = 0; i < allBundles.Length; i++) { - if (ab != null) - { - bundle = ab; - } + allBundleNames[i] = allBundles[i].name; } - Debug.Log($"Dissonance: Found AssetBundle {bundle.name}"); - return bundle != null; + Debug.Log($"Dissonance: Found AssetBundle {string.Join(", ", allBundleNames)}"); + return allBundles != null; } public static void Log() where T : UnityEngine.Object @@ -78,26 +77,32 @@ namespace Dissonance.Inspector public static Instance[] Inspect() where T : UnityEngine.Object { - if (bundle == null) Init(); - UnityEngine.Object[] assets = bundle.LoadAllAssets(); - Instance[] instances = new Instance[assets.Length]; - for (int i = 0; i < assets.Length; i++) + if (allBundles == null) Init(); + List allInstances = new List(); + foreach (var b in allBundles) { - instances[i] = new Instance(assets[i]); + UnityEngine.Object[] assets = b.LoadAllAssets(); + for (int i = 0; i < assets.Length; i++) + { + allInstances.Add(new Instance(assets[i])); + } } - return instances; + return allInstances.ToArray(); } public static string[] InspectNames() where T : UnityEngine.Object { - if (bundle == null) Init(); - UnityEngine.Object[] assets = bundle.LoadAllAssets(); - string[] names = new string[assets.Length]; - for (int i = 0; i < assets.Length; i++) + if (allBundles == null) Init(); + List allNames = new List(); + foreach (var b in allBundles) { - names[i] = assets[i].name; + UnityEngine.Object[] assets = b.LoadAllAssets(); + for (int i = 0; i < assets.Length; i++) + { + allNames.Add(assets[i].name); + } } - return names; + return allNames.ToArray(); } } }