Finding auto assets loaded from a bundle

At runtime and on device, is there a way to track ALL assets that have been loaded from a bundle, including auto-included assets that have been loaded as a result of other assets in the bundle being loaded?

If I add a prefab to a bundle but not a dependency it has (like a Texture) the Texture will get auto-included in the bundle. The prefab’s name will be in GetAllAssetNames() and it will show up in the Container section of the Asset Bundle Browser, but the Texture will not.

If I Ioad the Prefab either with LoadAllAssets or LoadAssetWithSubAssets it and all its dependencies will get loaded, but only the Prefab will be returned.

I saw a couple posts where you can use things like SerializedObject to get at the m_preloadTable of the bundle, but that only works in Editor.

While running a build on device (debug builds are OK), I need a way to determine which assets have actually been loaded from a bundle so I can get their runtime size with something like GetRuntimeMemorySize, know everything that has been loaded, and from where it was loaded.

The size of the Prefab doesn’t include its dependencies, and there doesn’t seem to be a way to correlate a Texture back to its source bundle.

I am not sure this is possible - when loaded at runtime, i am not sure the assets keep any reference to what actually caused them to load.

You could try the Memory Profiler package to see if it gives any leads, but i doubt it.

1 Like