Search Unity

Question Understanding the preloading and update logic....

Discussion in 'Addressables' started by Gamrek, Feb 15, 2021.

  1. Gamrek

    Gamrek

    Joined:
    Sep 28, 2010
    Posts:
    164
    Hello all,

    I am implementing addressable into my project. And I want to understand how to implement it correctly when I want to remotely add/update new content.

    Here is what I want to do: create groups which consist different game object, e.g. a group of character models for future update, a group of sword models for player to choose from. I want player to download the content before starting the game, which I understand I will need to get download size and display a progress download bar in front of player. And I want to show this every time there is an update.

    Now here are my questions:
    • If there is an update on existing group, e.g. a new character model. Do I need to add the new model into a new group? or I can add it to an existing "Character" group?
    • I know I can use "Addressables.GetDownloadSizeAsync" to get the download size and use "Addressables.DownloadDependenciesAsync" to download and store content in advance. But what if I add a new game object into a the same group after releasing? Does "Addressables.GetDownloadSizeAsync" will find out there are some new contents on the same group and return the size of the new content?
    • What does "LoadContentCatalogAsync" do? I read the document and I don't really understand how it works, it looks like it has something to do with content update. Can someone give me an example of how I can use it?
    • How can I simulate the process mentioned above on editor? Do I need to build the bundle etc if I want to try the "Addressables.GetDownloadSizeAsync" and "Addressables.DownloadDependenciesAsync" and update content? Or it can be simulated without building bundle?
    It will be great if any of you can help me to answer the questions above... thanks in advance...
     
  2. LucasHehir

    LucasHehir

    Joined:
    May 7, 2020
    Posts:
    74
    Hey, I can help out a bit I think. I'm not a seasoned pro at all so your mileage may vary.
    • You can simply add the new model into an existing asset group as long as that group is using RemoteLoadPath. Something else that comes into play here is the "Can/Cannot Change Post Release" setting, although it appears that even groups marked Cannot can, in fact, still be updated. That setting is a bit grey to me.
    • It will be able to do that, as long as the keys/resource locations you're passing in to DownloadDependenciesAsync include the bundle featuring the new asset. For example, the following should work:
      • In the Editor
        • Add a new character model to a pre-existing group
        • Give it the asset label "model_character"
        • Perform a content update
        • Upload changed assetbundle/s
      • At run-time
        • Request all resource locations with the label "model_character" using LoadResourceLocationsAsync
        • Pass the IList<IResourceLocation> it gives you into GetDownloadSizeAsync and DownloadDependenciesAsync
        • Your bundle change will be reflected in those actions. DownloadSizeAsync should show the number of bytes difference and DownloadDependencies should... download them.
    • Addressables gets the location of each resource via its content catalogue file. Hypothetically, it's possible to pull in a previously unknown content catalogue from a remote URL and then use it to do familiar operations (GetDownloadSize, DownloadDependencies, etc) on assets. In other words, the catalog file doesn't have to be bundled in the app binary. However I personally can't vouch for this and haven't successfully used it myself (although I'd love to try).
    • Set your Play Mode Script (Window > Asset Management > Addressables > Groups > Play Mode Script) to Use Existing Build. Then build your assetbundles for remote deployment, upload them, and the Editor should attempt to pull them in as expected. I'm not super experienced with this though and usually test directly on-device.
     
    Gamrek likes this.
  3. Gamrek

    Gamrek

    Joined:
    Sep 28, 2010
    Posts:
    164
    Thanks @LucasHehir, I will try it out. It also has API to clear the stored data out. And I was wondering if I ever need to use it. I personally cannot think of a use case to do this in real life situation. Thanks!