Search Unity

Understanding dependencies and scenes, etc.

Discussion in 'Addressables' started by therobby3, Oct 21, 2020.

  1. therobby3

    therobby3

    Joined:
    Jan 30, 2019
    Posts:
    131
    I've been reading quite a bit on dependencies and addressable/asset bundles in order to split my game main file size up. However, I'm having a bit of trouble fully wrapping my head around how some of this dependency stuff works. I think I understand it for a minute, and then I get myself confused again. >.< I already load my game music perfectly using addressables, but it's a pretty simple implementation. However, it's when these dependencies come into play that I start getting confused. Take the following simple example:

    Scene1 (built into the final build)
    -Contains 5 instances of the same tree prefab placed in the scene, each with the same tree texture. (so 1 prefab, 1 tree texture)

    Scene2 (addressable scene)
    -Contains 8 trees placed in the scene, each with a tree texture. Uses the same tree prefab and texture as scene 1.

    Scene3 (addressable scene)
    -Contains 4 trees, each with the same tree texture. (again, same as above).


    Would doing the the above duplicate the tree prefab and tree material 3 times? It seems to me that it would be duplicating assets. If so, I'm rather confused on how to avoid this happening. Seems like it should be so simple, but I'm getting myself pretty confused. >.<
     
  2. therobby3

    therobby3

    Joined:
    Jan 30, 2019
    Posts:
    131
    So I've been reading a bit and experimenting and I think I have some answers to my own question:

    Yes, the tree prefab and material would be duplicated 3 times as originally thought. If however, I independently also marked the tree prefab and the material also as addressables, they would not be duplicated in each scene addressables. The Addressable system would recognize that and reference them in both scene2 and scene3. Meaning I would then only have 2 duplicates. I think fixing the addressable duplicate in scene1 (build into final build) would be impossible in the given case. If however I made scene1 also an addressable, all 3 would reference the same tree and material, thus getting it down to only 1 and not having any duplicates.

    Someone correct me if I am wrong, but this seems to be the case. This makes sense, but also seems like the only solution here would be to go through every object in every scene, and every material, texture, etc and make them ALL addressables. Seems like that would be a lot of odd work.

    New Question
    This leads me to a new question then, related to how addressables are loaded. Say I had prefab1 and prefab2 which both referenced the same dependency texture. If I call LoadAssetAsync() on prefab 1, then call LoadAssetAsync() on prefab 2, is bandwidth/load time getting waisted and having that dependancy texture loaded twice? Or does the system notice that, and only load it once?

    There's quite a bit that is confusing with all of this, so I'm just trying to make sense of some things that I can't find concrete answers to in the documentation and such.