Search Unity

Load content from server that is not included in the build itself

Discussion in 'Addressables' started by Tayfe, Feb 4, 2020.

  1. Tayfe

    Tayfe

    Joined:
    Nov 21, 2011
    Posts:
    103
    We want to upgrade our content loading system and came across addressables which seems to be the future system for loading content on demand. But on the first look it looks very confusing and complex. That's why I have a question which I want to be answerd first before I start learning this new system:

    Is it possible to load assets from a server that are not included in the build?


    The few articles and tutorials I have read so far suggest that addressables are just extending the normal assets by the function that they can be excluded when building the application, stored on a server and be loaded when desired.
    But all I have seen so far is that it is only possible to load assets that have been imported to the project. I mean like when I have a bunch of prefabs and I want them to be loaded on demand from a server I have to include all prefabs into my project first. Then they are marked as addressable and when building the project they can be exluded again. But they need to be marked as addressable once. So it seems like there is no way to include assets that do only exist on our server.
    But we want to be able to load content from the server that has never been in our project before. We just want to build a small sized app that can load any scene file that we host on our server and where we can keep adding new scene files without needing to build a new application

    I hope that it's possible to understand our problem. If not I will try to explain it again. Maybe it's also just so confusing because I am so confused by this new system.
     
  2. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    586
  3. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,188
    I have the same question. How do I load content from a server that never existed in the Unity project and without having to re-build and update my app?
     
  4. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,208
  5. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,188
    I'm afraid not really. The docs tell me that there's a catalog file stored on the server, but it's not clear if I can add to this catalog additional assets and load them from my app without having to re-build and re-deploy the app itself. Additionally, it continues to explain that they recommend branching the source repository of my project if I need to make changes to static content, which would reorganize a lot of content, but that leaves me with the question, what would happen after that if I need to make a change a second time? Why wouldn't I make my entire app dynamic to avoid this issue? Then finally, the docs describe the process of updating content, but I read this as only making changes to groups of assets which already exist, so basically changing a texture or prefab, etc. But can I add a new group with new prefabs and let my old app download and use them without having to build the player again? I feel like the docs are really missing some use-case examples.
     
  6. Tayfe

    Tayfe

    Joined:
    Nov 21, 2011
    Posts:
    103
    Thanks! It seems exactly like what I am looking for. Sadly it's not working for me. I tried to implement it but I get stuck on trying to load the dependencys.

    Code (CSharp):
    1. AsyncOperationHandle handle = Addressables.DownloadDependenciesAsync("Tree");
    Maybe I don't understand what the key stands for? I changed it from decor to Tree because I thought that key is equal to the name of one of the objects included in the catalog? So far I recieve the following error message:

    That's how my addressables setup looks like:

    Screenshot_1.png

    What is the key supposed to be? Do I have to add the path of the prefab or something like that? Tried around a little but couldn't figure out a solution yet.

    I appreciate any kind of help :)

    EDIT:

    It seems like I could answer at least on of my questions myself:


    Yes! I took a look into the catalog.json file and found a list of keys there inside with the full path to my prefab is listed. So I tried it again and this time it worked (maybe I had a spelling mistake before or something). So thats my new line:

    Code (CSharp):
    1. AsyncOperationHandle handle = Addressables.DownloadDependenciesAsync("Assets/_Project/Prefabs/Tree.prefab");
    But this doesn't solve that problem at all. I just changed the error message:

    It confuses me that the RemoteAssetBundleProvider is unable to load from localhost since it's not even supposed to load from localhost? So how can I change this url?
     
    Last edited: Feb 7, 2020
  7. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    586
    In your group settings, change the load path to remoteloadpath.
    Then in profile settings, change remoteloadpath to
    {MyNamespace.MyClass.AssetPath}/[BuildTarget]
    .
    In your code, create a public static string property that matches what you put inside {}. Set that to the path you want to load from before you initialize addressables. The setter can be private.


    Code (CSharp):
    1. namespace MyNamespace
    2. {
    3.     public static class MyClass
    4.     {
    5.         public static string AssetPath { get; set; }
    6.     }
    7. }
     
    Tayfe likes this.
  8. Tayfe

    Tayfe

    Joined:
    Nov 21, 2011
    Posts:
    103
    Thanks a lot, I got it working with your help!
     
  9. stevenchristian20

    stevenchristian20

    Joined:
    Dec 23, 2019
    Posts:
    29
    Hey,

    I am looking for a way to implement downloadable content to my mobile app after the app is build. I have been looking into Addressables and have prefabs of my content hosted on Firebase. For some reason i am stuck trying to download the addressables onto my device and initiating them onto my scene. I have a menu screen and a scene that uses the downloaded content. Would you mind sharing the script you got working.