Search Unity

Modding with Addressables?

Discussion in 'Addressables' started by laurentlavigne, Jul 11, 2018.

  1. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    2,012
    Is there a plan for an inbuilt modding utility in Addressables or you think modding is still too specific to the games to be part of the engine?
     
    andrew-lukasik likes this.
  2. PaulBurslem

    PaulBurslem

    Unity Technologies

    Joined:
    Oct 7, 2016
    Posts:
    46
    We don't have plans to specifically support mods, but you can dynamically add IResourceLocators (which are essentially the ContentCatlogs) at runtime. When you load your collection of mods, each one could have the path to load its catalog. Predefined/known labels can be used to retrieve all assets that are the entry points to the mods (prefabs or other data).
     
    andrew-lukasik likes this.
  3. Vallar

    Vallar

    Joined:
    Oct 18, 2012
    Posts:
    151
    Excellent question @laurentlavigne I was about to ask the same question.

    Could you please elaborate on this further? We are currently planning to use AssetBundles; we group all our meshes in StreamingAssets in folders based on their type (buildings, characters, items, etc...) and then we load these at run time and when we Instantiate an object at run time, we assign their mesh, sprite, data, etc... using the AssetBundles loaded data.

    How does one do the same with Addressable Assets?

    I kind of understand in a vague way what you've mentioned but not sure I follow how to implement that; like for example what is a ContentCatalog?

    Would what you said mean that instead of AssetBundles I'd use Addressable Assets, load based on group (buildings, characters, items, etc...) and then use the name perhaps of the "Addressable Asset" to assign to the object same way we're doing with Asset Bundles?

    EDIT: Crap, I just realized I necroed the post... I didn't see this is from July. Should I make a new post?
     
  4. nTronz

    nTronz

    Joined:
    Nov 16, 2015
    Posts:
    3
    @Vallar, I came to ask the same questions.

    What functions need to be called to Load said catalog from a predefined user folder? Do users need to have a pre-built Addressable AssetGroup?

    I think we just need some specific functions to understand. I'll make a new thread if we don't get a reply soon.
     
  5. pdinklag

    pdinklag

    Joined:
    Jan 24, 2017
    Posts:
    36
    Necro or not, I'd like to second the questions since they aren't answered yet @PaulBurslem . Nothing seems to be really documented and I cannot put the pieces together here. I see there's a method Addressables.LoadContentCatalog, but here are some specific questions:
    • What exactly is a content catalog (as opposed to an asset bundle)?
    • How do we use that method? What path do we pass to it, relative to what? What does it point to / what is expected to be found at that path - an asset bundle file? Something like that catalog.json?
    • How will modders prepare a content catalog for their mods?
    • How can the game get a list of available content catalogs ("installed mods") to load? Do we put them somewhere under StreamingAssets and scan for certain JSON files using System.IO?
     
    bamial_grehk and Sylmerria like this.
  6. Sylmerria

    Sylmerria

    Joined:
    Jul 2, 2012
    Posts:
    232
  7. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    437
    I'd also like to get some clarification about how to actually implement modding with Addressables.
     
  8. Loofou

    Loofou

    Joined:
    Aug 22, 2012
    Posts:
    16
    A second this. A bit of clarification or at least pointers to documentation or even just code that can help with this would be very helpful indeed.
     
  9. pdinklag

    pdinklag

    Joined:
    Jan 24, 2017
    Posts:
    36
    I see so much activity in this forum, yet the developers (atm it's @unity_bill ?) seem to actively avoid threads with these kinds of questions.

    Addressables are worthless to me with all these open questions. I have long built my own system since I posted my very concrete and presumably easy to answer (for the devs) questions 4 months ago. Probably a lot of other people have as well while Addressables are slumbering in this undocumented "no idea how to use it" state. And the more time progresses with this left unanswered the less likely it becomes that I'm ever interested in using them, because I will have to migrate.

    If you want people to use this feature, please answer their questions (and within less than a year...) or provide a solid documentation.
     
    Last edited: Aug 7, 2019
    bamial_grehk and Sylmerria like this.
  10. danilonishimura

    danilonishimura

    Joined:
    Jul 13, 2010
    Posts:
    49
    @pdinklag I'll try my best to help you. If you guys think I'm wrong, please point it out because I'm also learning about it.

    AFAIK, ContentCatalog is a file that describes the relationship between the key and the asset. At runtime, the catalog is loaded, parsed and becomes a Resource Locator, where it maps the addressable name to the actual asset. In the AssetBundle you reference the asset by its path, where in the addressable, you access it by a name. The advantage is that whenever a catalog is loaded (you can load multiple catalogs), you get the asset by a single call Addressables.LoadAssetAsync(string key) or Addressables.InstantiateAsync(string key), and it will figure out where is that asset from the many bundles registred in the ResourceLocators.

    Addressables.InstantiateAsync(string key), where key is the AddressableName you put in the AddressableWindow:
    upload_2019-8-7_18-15-18.png
    In this case, I'd use:
    var instantiateOp = Addressables.InstantiateAsync<GameObject>("VIEW_Test_Capsule")// it returns a AsyncOperation.
    while (!instantiateOp.IsDone)
    {
    yield return new WaitForEndOfFrame();
    }

    var myCapsule = instantiateOp.Result; // The instantiated capsule object.

    If you use the Addressables.LoadAssetAsync, it will return a non instantiated instance of the asset. You can instantiate it using Instantiate(myCapsule);

    There are more overloads and methods in the Addressables class. Please refer to https://docs.unity3d.com/Packages/c...1/manual/AddressableAssetsGettingStarted.html and https://docs.unity3d.com/Packages/c...ityEngine.AddressableAssets.Addressables.html

    Honestly, I don't know if there is a "right" way to do it. Updating content using addressables can be easy. Setting up a webservice that returns a list of catalogs containing the updated assets, load them, and you should be good to go. Updating game logic is bit trickier. Some people use reflection, some people use runtime scripting (lua, python, etc). There are many approaches, you just have to be sure they work on your target environment.


    The way I see, the easiest way is to put the catalogs in a webserver and download them from there, where you can write server scripts to filter what catalogs you want to be available. You can also put the catalogs in your project, but it makes more complicated to update because you'll have to publish a update of your game to update the assets. Loading them from another source definitively makes it more scalable.
     
    pdinklag likes this.
  11. senfield

    senfield

    Joined:
    Apr 1, 2019
    Posts:
    21
    You can load a catalog manually using Addressables.LoadContentCatalogAsync(path);
    The path has to be the absolute path to the catalog.json.

    Modding implies that you might want to have a separate Unity project from the one used to create the original game. To do that, you have to pay very close attention to load path and build path settings you use in the Addressable Asset settings for the mod project. They must match where it will be loading from once it is installed in the game.

    Also, if you want to use a script on a modded object it has to be present in both the game and the mod project.