Browse Source

Use all assetbundles instead of only last

master
NGnius (Graham) 5 years ago
parent
commit
ae4dc56e84
1 changed files with 25 additions and 20 deletions
  1. +25
    -20
      Dissonance/Inspector/AssetInspector.cs

+ 25
- 20
Dissonance/Inspector/AssetInspector.cs View File

@@ -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<T>() where T : UnityEngine.Object
@@ -78,26 +77,32 @@ namespace Dissonance.Inspector

public static Instance[] Inspect<T>() where T : UnityEngine.Object
{
if (bundle == null) Init();
UnityEngine.Object[] assets = bundle.LoadAllAssets<T>();
Instance[] instances = new Instance[assets.Length];
for (int i = 0; i < assets.Length; i++)
if (allBundles == null) Init();
List<Instance> allInstances = new List<Instance>();
foreach (var b in allBundles)
{
instances[i] = new Instance(assets[i]);
UnityEngine.Object[] assets = b.LoadAllAssets<T>();
for (int i = 0; i < assets.Length; i++)
{
allInstances.Add(new Instance(assets[i]));
}
}
return instances;
return allInstances.ToArray();
}

public static string[] InspectNames<T>() where T : UnityEngine.Object
{
if (bundle == null) Init();
UnityEngine.Object[] assets = bundle.LoadAllAssets<T>();
string[] names = new string[assets.Length];
for (int i = 0; i < assets.Length; i++)
if (allBundles == null) Init();
List<string> allNames = new List<string>();
foreach (var b in allBundles)
{
names[i] = assets[i].name;
UnityEngine.Object[] assets = b.LoadAllAssets<T>();
for (int i = 0; i < assets.Length; i++)
{
allNames.Add(assets[i].name);
}
}
return names;
return allNames.ToArray();
}
}
}

Loading…
Cancel
Save