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 Addressable asset path in builds

Discussion in 'Addressables' started by MegatronusV, Jul 25, 2020.

  1. MegatronusV

    MegatronusV

    Joined:
    May 2, 2020
    Posts:
    16
    In play mode, I'm able to load an addressable asset via LoadAssetAsync() by passing in a string path like "Assets/something/file" but this does not seem to work when I build the game since It cant seem to find the directory. Is there something I'm missing? I've tried to do something like Addressable.BuildPath+"/Assets/something/file" but that doesn't work either. (and I use Path.DirectorySeparatorChar in the code, not slashes).

    So my question is, for local assets, how do you address the asset by its path?
     
  2. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    566
    "Assets/something/file" is not just the path, it is the actual address (it's the default generated when you make the asset addressable, and you can change it). You cannot load assets by their path, only by their address, so passing that same string in editor or build should work. It also depends what platform you are running on: local directories do not work in WebGL (unless you did a build+run).
     
  3. MegatronusV

    MegatronusV

    Joined:
    May 2, 2020
    Posts:
    16
    yep so as long as I use the address as is, it should work in build, yeah? I think my issue is then related to a json file that isn't addressable and not in any streaming assets/resources folder so its not being loaded into the build. Because I load my addressables using some relevant info fetched from the json. So to make sure the json files are loaded in the final build, do I just dump them in a streaming assets folder or is there a "better/correct" way?
     
  4. dogboydog

    dogboydog

    Joined:
    Nov 23, 2012
    Posts:
    53
    How are you trying to load the JSON file? If you want to use Addressables to load it, I think you'd either have to mark it Addressable and save a reference to that somewhere, or go to a related asset in your project that IS addressable and add something like a TextAsset reference, and drag the JSON file in there. If you do the latter my understanding is that Addressables would detect the dependency and include it in the bundle as an "implicit" asset, "explicit" being things you mark as addressable and include in a group.

    You can check all the items in the bundle to make sure they're in there by going here
    upload_2020-7-25_10-34-46.png
    upload_2020-7-25_10-34-38.png

    Either way, you shouldn't have to move the JSON files into another folder. That's one of the nice things about this package
     
    kurotsmile likes this.
  5. MegatronusV

    MegatronusV

    Joined:
    May 2, 2020
    Posts:
    16
    I'll try the dependency route, thanks!
     
    dogboydog likes this.