How to generate a chain of dependencies for a specific bundle using the manifest (assetbundlemanifest)?
I want to automate the loading of content in the project a little, but so far I have to manually set the order of loading bundles.
Let’s say I have such content:
Shaders (must be loaded first)
Materials (must be loaded second
Models (must load third)
Prefabs (loaded last)
I want to tell you right away that I’m not going to use Addressable because I want to control the loading and unloading of content
Why is the order that important? The prefabs bundle could easily be loaded first, as long as it’s dependencies are loaded when you instantiate a prefab from it.
You can use the getalldependencies method of the manifest to fetch all dependencies recursively
If the bundle with prefabs is loaded first, it will not find links to materials and the entire prefab (if it has a Mesh) will be pink. And if the bundle of materials is loaded before the bundle with shaders, then the materials will be pink, I already checked it
It does not matter which order you load Bundle 1 and Bundle 2, the important takeaway is that Bundle 2 is loaded before loading the Material from Bundle 1.
I just made a quick test case, a scene referencing a material referencing a texture, each in a different bundle. It works regardless of in which order I load the bundles, as long as they’re all loaded when I instantiate the asset referencing them (the scene in my case)