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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

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,268
    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,268
    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!