Search Unity

How to make new content known to the addressables system at runtime (for modability)

Discussion in 'Addressables' started by tylerw-savatronix, Mar 2, 2019.

  1. tylerw-savatronix

    tylerw-savatronix

    Joined:
    Nov 10, 2013
    Posts:
    77
    Hi there,

    The addressables system looks like it'll be incredibly useful for adding modability to our game. We were considering switching over to straight asset bundles, but addressables look like they're going to be the preferred way (especially since content won't be limited to asset bundles, but those can also be used giving options to modders and making sure we don't have to care what option they choose).

    What not obvious to me is how we would be able to make the addressables system aware of new content at runtime from semi-arbitrary folders (where only the root is known).

    The desired behavior would be a mods folder, with each mod having its own subfolder (of whatever structure the mod author desires), and ensuring the Addressables system can discover any addressables in that mod folder recursively when the game is started up.

    We don't want to try dumping all of this into the streaming assets folder or otherwise making use of that folder.

    Is that a thing that's currently possible, and if not is it something that's planned?
     
  2. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    709
    You can load additional catalogues at runtime. That would be how I would do it at least.
     
  3. tylerw-savatronix

    tylerw-savatronix

    Joined:
    Nov 10, 2013
    Posts:
    77
    Can you point me towards any documentation about doing that please? I can't seem to find anything.
     
  4. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    709
    Unless I'm massively misunderstanding what your needs are, the API you are looking for is Addressables.LoadCatalogsFromRuntimeData(). One thing that is a bit annoying about it is that you need to save it to disk and pass it a path to it, rather than just provide it the textual data directly.
     
    MNNoxMortem likes this.
  5. JakHussain

    JakHussain

    Joined:
    Oct 20, 2016
    Posts:
    165
    do you need to pass the catalog.json or catalog.hash file? and would it still work on a server hosted file or does it HAVE to be on disk?
     
  6. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    709
    Right, I just had a look, as it's been a while since I implemented this, and what you pass is a settings.json file that references your catalogues. Generally, that file is generated when you build your bundles. We leave our catalog files on the server, download the settings.xml file into Application.persistentDataPath with a UnityWebRequest and call Addressables.LoadCatalogsFromRuntimeData() on that path.
     
  7. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    709
    Reading the 0.6.6 change log, the following seems relevant:

    • Renamed Adddressables.LoadAddtionalCatalogs to Addressables.LoadContentCatalog and now it takes the path of the catalog instead of the settings file
     
    MNNoxMortem likes this.
  8. JakHussain

    JakHussain

    Joined:
    Oct 20, 2016
    Posts:
    165
    i tried this on 0.6.7 for my remote build and it throws an InvalidKeyException D;
     
  9. senfield

    senfield

    Joined:
    Apr 1, 2019
    Posts:
    28
    Has anyone gotten this to work yet?
     
  10. JakHussain

    JakHussain

    Joined:
    Oct 20, 2016
    Posts:
    165
    To this day I still haven't. Apparently although the API exists, it's buggy undocumented and isn't as simple as it may seem. Now that the roadmap for the version 1 release has been delayed from like a month ago to the end of the year, I've kind of given up until there's actually a release that fleshes this feature out or documents it better.
     
  11. senfield

    senfield

    Joined:
    Apr 1, 2019
    Posts:
    28
    After some chatting with unity bill, I found out LoadContentCatalog needs an absolutely absolute path for the catalog json. So like this:
    Addressables.LoadContentCatalog("C:\\Users\\yourawesomeuserhandle\\Documents\\repo\\YourProject\\Library\\com.unity.addressables\\StreamingAssetsCopy\\aa\\Windows\\modcatalog.json").Completed += CatComplete;
     
    unity_bill likes this.
  12. DarkVerse

    DarkVerse

    Joined:
    Jan 9, 2017
    Posts:
    40
    I seem to recall reading somewhere that Addressable Assets loaded in this scenario (ie new content that was not known at buildtime) cannot have new scripts. This would seem to be a major roadblock to releasing new content (with new behaviour via new scripts) in this scenario. Is this the case? If so, is there a plan to improve on this?
     
  13. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    709
    This is the case with asset bundles in general. Whether an improvement would be at all possible depends on the platform. On AOT platforms (like iOS) it will never be possible.
     
unityunity