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

Q: Can Addressables be used to load content post build?

Discussion in 'Addressables' started by jbove2, Dec 7, 2019.

  1. jbove2

    jbove2

    Joined:
    Oct 15, 2019
    Posts:
    2
    Hello,

    I've been doing a fair amount of reading on addressables, and wanted to confirm a functionality before I began down the long road of completely understanding them and implementing them in my project. I wasn't able to find the answer to this question anywhere online, and would appreciate it if anyone could give me a hand.

    I'd like to know if Addressables can be used to load content after a project is built.

    I.e. I have an already built project, and want the ability to download new prefabs from an external source (maybe a download server) which can be utilized by the already built/deployed project

    Relatively new to programming in Unity, and am grateful for any help!

    Thanks!
     
  2. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    736
    Hey @jbove2 so, Addressables is meant for loading new content post build to a project. Addressables will need to be baked into your games code and built assets. If you have an already built and deployed project there's nothing Addressables can do to add that in. If you're creating a project and use Addressables for your content loading, then yes. You can build Remote Asset Groups which would be the assets you plan on putting on a CDN somewhere. Then, post release, if you'd updated any of the Remote Assets the new data would get pulled into the game and used.

    I hope that answers your question!
     
    jbove2 likes this.
  3. sinaari

    sinaari

    Joined:
    Jan 28, 2019
    Posts:
    37
    From this answer it is not clear if it is possible to push entirely new content to the game via Addressables? By "entirely new" I mean content that is not in any way known of during the build of the application itself, and is later, as an afterthought, uploaded to CDN and contains entirely new assets that did not exist and were never planned for during the application build? In other words, just a regular content update that is common for many games.

    How would you handle structuring and referencing the assets in such case? Could you please give some example code for that?
     
    Last edited: Dec 11, 2019
  4. jbove2

    jbove2

    Joined:
    Oct 15, 2019
    Posts:
    2
    hey @DavidUnity3d, really appreciate the response.

    I think @sinaari added some nice clarification to the question, I'm looking to download and use entirely new prefabs/assets which are on a CDN. Do you feel that Addressables are the best way to go about it, and if they are, some example code would be wonderful.

    Thanks a lot for the help!
     
  5. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    736
    So, if your game is built using Addressables in its loading/unloading/etc. code then yes, you can get totally new content that is unknown to the original build.

    Lets say, for instance, you create a game that has 2 playable character options. You're using Addressables so you can use the Addressables labels to label all your character prefabs that are part of the Addressable system with something like "characters". Your code to load all your characters is something like (but probably more sophisticated):
    Code (CSharp):
    1. Addressables.LoadAssetsAsync<GameObject>("characters", (go) =>
    2.         {
    3.             if (go != null)
    4.                 AddGameObjectToCharacterRoster(go);
    5.         });
    then, 3 months later you've got 5 new characters you want to add. So in your project you can add those prefabs to Addressables, mark them with the "characters" label, and then perform a Content Update through the system. After that you'll have a new set of data you can replace on your old data with on your CDN. Now when the LoadAssetsAsync call happens it should see new data remotely and download it. This will give you access to all 7 characters without having to change your actual app binaries at all.

    In a similar fashion lets say you have a material on some prefab and you make the prefab Addressable. Then later you update the material, perform a Content Update, and put the newly built data on your CDN. When that prefab gets instantiated again it'll pull the new data and use your updated material.

    This is, of course, a very simple scenario but at a high level shows what Addressables is doing. If I understand your question my answer is yes, this is what Addressables is for. You just have to make sure the game code shipped with your game handles new data that gets added.

    I hope that starts to answer some of your question. I think my answer might have been confusing because the way I interpreted your original question was that you already had some built game out in the wild and were hoping to use Addressables to update that games content. That is not something that's possible.

    Thanks!
     
    jbove2 likes this.
  6. sinaari

    sinaari

    Joined:
    Jan 28, 2019
    Posts:
    37
    Yes, thank you very much, this answers the question!

    I understand, the game has to be built/rebuilt to include the new Addressables management facility, but other than that the possibilities that you are describing are pretty much what I would have wanted to know. So, I can have a remote manifest with lists of resources and resource labels, and a corresponding mechanism to handle that dynamic data inside the of the game build, and that would allow to fetch totally new asstes to an existing build. That's perfect.

    I am not sure if new C# code can be loaded like that, though, like if the assets can have new components on them that were not available during the build time. This is not critical for my personal current use case, but it might be an important question for other people.
     
  7. Hash-Buoy

    Hash-Buoy

    Joined:
    Jan 4, 2014
    Posts:
    33
    We have a similar situation, but the new characters are going to be around 300 and growing.
    So every time the content update is performed, we don't want the user to download the whole bundle of 300 characters (which will be huge and will take a lot of time), rather he should be able to download only one character which he selects.
    So my question is, can each character be a separate asset? So that the download size is small?
    And since they were not present during the initial build. Can the app still recognize and download these new content groups?
     
  8. awais378

    awais378

    Joined:
    May 29, 2021
    Posts:
    1
    @Hash-Buoy Yes you can. Just Asynchronously download the single character and use it. You will have to know its separate URL to do that.
     
  9. morhun_EP

    morhun_EP

    Joined:
    May 11, 2021
    Posts:
    9
    No, new components need a new game build.
     
  10. morhun_EP

    morhun_EP

    Joined:
    May 11, 2021
    Posts:
    9
    In our scenario, we want to load different characters for different players and minimize the download sizes. Can we add new Addressable groups for each new character post-build?
     
  11. FlightOfOne

    FlightOfOne

    Joined:
    Aug 1, 2014
    Posts:
    659
    As long as the code does not change, yes.
     
    morhun_EP likes this.