Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Dependencies duplication

Discussion in 'Addressables' started by lucasrodriguezroge, Jun 12, 2023.

  1. lucasrodriguezroge

    lucasrodriguezroge

    Joined:
    Feb 27, 2022
    Posts:
    4
    Greetings

    Our game is divided into content/chapters that are self contained, so we built a simple system where we have a base scriptable object that has inside the variables we need (prefabs, textures, etc) for each content. These vars are always asset reference, not direct, and can sometimes have a complex hierarchy (like a scriptable object, that has a direct scriptable object referenced that eventually has the asset references).

    This is so far not working as intended, and the download size we are getting when trying to access to a content is huge instead of as it should be.

    How are asset references handled in this scenario? We know that when downloading an addressable the system also downloads its dependencies, but in the case of asset reference variables, is the actual file considered as a reference or just the reference (pointer)? I suppose we could simplify this by using string paths instead of asset references, but this would obviously mean reinventing the wheel when we have asset references.
     
  2. pillakirsten

    pillakirsten

    Unity Technologies

    Joined:
    May 22, 2019
    Posts:
    346
    Hi @lucasrodriguezroge by "asset references" are you referring to the AssetReference class? https://docs.unity3d.com/Packages/com.unity.addressables@1.21/manual/editor/AssetReferences.html

    An AssetReference simply stores the guid of an addressable asset. Similar to string paths, they are keys used to identify and locate assets.

    An AssetBundle dependency occurs when an asset in one bundle references an asset in another bundle. So for example a scriptable object with a GameObject or Texture variable set. More info available here: https://docs.unity3d.com/Packages/c...lications-of-loading-assetbundle-dependencies
     
  3. lucasrodriguezroge

    lucasrodriguezroge

    Joined:
    Feb 27, 2022
    Posts:
    4
    Hey @pillakirsten thanks for your answer.


    Yes I meant that the SOs have exposed AssetReferences class fields, I follow that they are just pointers/guid as you mention, thats why I'm not sure of what is happening for the moment.


    So just to confirm, if I have a ScriptableObject with 2 fields:

    • SpriteAssetReference spriteA: some big sprite of lets say 10MB

    • Sprite spriteB: small sprite of 2MB

    If I do Addressables.DownloadDependenciesAsync with this SO key, its download size will be around 2MB (aprox) instead of 12MB right? (the direct sprite makes most of the weight since the other asset reference is just a GUI as you mention).


    Thanks