Search Unity

Direct references vs Asset references

Discussion in 'Addressables' started by Fakkau, Oct 2, 2019.

  1. Fakkau

    Fakkau

    Joined:
    Mar 11, 2013
    Posts:
    22
    Probably a stupid question, but here goes. I'm new to Addressables, trying to figure it out.

    When I mark an asset as Addressable and add it to a group in the Addressables window, it gets bundled in a Asset Bundle, right? I can now reference that asset using either a direct reference or an Asset Reference.

    Say I make a build of the game and use a direct reference to instantiate the asset. This will work even if I delete the Asset Bundle that I put the asset into. Does that mean that the asset is stored both inside and outside of the bundle? (Because how else would the direct reference still function?)

    TL;DR: Why do direct references still work if the Asset Bundles containing the referenced assets aren't loaded? Does that mean that the asset is stored both inside and outside of the bundle?
     
    yyhvs1995 likes this.
  2. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,277
    The build will duplicate the asset, one found in the asset bundle, the other found in the base build.
     
  3. Fakkau

    Fakkau

    Joined:
    Mar 11, 2013
    Posts:
    22
    Hmmm ok thank you, so what would the correct workflow be in order to prevent it being duplicated? If I simply don't make a direct reference ANYWHERE, does that prevent it from being placed in the base build?
     
    phobos2077 likes this.
  4. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,277
    If you don't have a direct reference anywhere, it will solve the duplication problem.
    There's also an automated solution: https://docs.unity3d.com/Packages/c...ycle.html#check-duplicate-bundle-dependencies

    I personally am having some issues with the latter, it takes a very very long time to solve the solution, and it seems quite buggy. But it's there.
     
  5. Fakkau

    Fakkau

    Joined:
    Mar 11, 2013
    Posts:
    22
    Alright that's good to know, thank you!