Search Unity

Help Wanted Generating depedency chain for specific bundle

Discussion in 'Asset Bundles' started by ep1s0de, Jan 13, 2021.

  1. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    123
    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
     
  2. nilsdr

    nilsdr

    Joined:
    Oct 24, 2017
    Posts:
    353
    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
     
  3. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    123
    No, it won't work that way...

    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

    This is also described in the dependency manual
    https://docs.unity3d.com/Manual/AssetBundles-Dependencies.html
     
  4. nilsdr

    nilsdr

    Joined:
    Oct 24, 2017
    Posts:
    353
    no, the manual says the exact opposite:

    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)
     
  5. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    123
    The order of loading bundles is not important until the prefab itself is loaded from the bundle?

    For example I loaded the bundles in different order and after loading the bundles I load the prefab and links to it are automatically detected?
     
    nilsdr likes this.
  6. nilsdr

    nilsdr

    Joined:
    Oct 24, 2017
    Posts:
    353
    that is how it should work
     
  7. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    123
    Apparently the developers did something, a year ago I faced such a problem and loaded the bundles in order. It's not just that I have such a question :)

    Thanks for the help...
     
unityunity