Last active
September 10, 2020 17:31
-
-
Save rickyah/98e63d7c91d3ae06be38848a80a00c83 to your computer and use it in GitHub Desktop.
Script to print all asset bundles of the project and its dependencies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[MenuItem("AssetBundles/Print all Asset Bundle names")] | |
static void PrintAssetBundlesToDebugConsole() | |
{ | |
var sb = new StringBuilder(); | |
var globalTimer = new Stopwatch(); | |
var timer = new Stopwatch(); | |
globalTimer.Start(); | |
timer.Start(); | |
var assetBundles = new List<string>(AssetDatabase.GetAllAssetBundleNames()); | |
timer.Stop(); | |
sb.AppendLine($"Retrieved list of Asset Bundles: {assetBundles.Count} [{timer.ElapsedMilliseconds /1000.0}s]"); | |
timer.Reset(); | |
foreach(var assetBundle in assetBundles) | |
{ | |
bool recursive = true; | |
timer.Start(); | |
var dependencies = AssetDatabase.GetAssetBundleDependencies(assetBundle, recursive); | |
timer.Stop(); | |
sb.AppendLine($"{assetBundle} [{timer.ElapsedMilliseconds /1000.0}s]"); | |
foreach(var dependency in dependencies) | |
{ | |
sb.AppendLine($"\t{dependency}"); | |
} | |
timer.Reset(); | |
} | |
globalTimer.Stop(); | |
sb.AppendLine($"Total elapsed time: [{globalTimer.ElapsedMilliseconds /1000.0}s]"); | |
Debug.Log(sb.ToString()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yep, it works con Unity 2018. Have you tried generating the assets once? Maybe Unity is using an internal database or something