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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Addressables & RemoteLoadPath

Discussion in 'Addressables' started by Rob-Hafey, Jun 12, 2020.

  1. Rob-Hafey

    Rob-Hafey

    Joined:
    Jul 24, 2014
    Posts:
    12
    I am new to addressables and had a question about the RemoteLoadPath. I created a new group placed all my assets and there and successfully loaded all my text and texture assets (WOOHOO). Once I got the code running I wanted to experiment with the remote loading of data from my website. This is when things started getting weird.

    I set up a new profile (server) in which I had the RemoteLoadPath pointing to my addressables folder URL on my site. I switched to the server profile and then set the LoadPath to be RemoteLoadPath. I created a build which produced a .bin file which I moved to my server into that directory. I then set the play mode to Use Existing Build.

    The first strange thing that happened was that the Addressables system wouldn't ever try to load from my path even though the profile was set to Server. I tried for a few hours to get the system to load without success. It continued to point to my LocalLoadPath and would fail every time when playmode was set to Use Existing Build

    I figured that I was doing something wrong, we had a lightning storm coming so I shut down and went and got another cup of coffee. About an hour later I loaded Unity again and BINGO the whole thing worked the first time. Files loaded from the remote folder using the RemoteLoadPath. That was kinda f'ed up so first question is why did it suddenly start working?

    At this point I was happy it was working but still skeptical. So I decided to change the name of my server directory path to see if it would fail. Nope kept working. Then I changed my RemoteLoadPath to point to something that didn't exist and BOOM still worked.

    This is strange enough that I have to ask a question. I am hopeful that I am just overlooking something. Caching maybe? Or maybe I am just not using remote even though the Load Path = RemoteLoadPath?
     
  2. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    566
    Funny enough, I just ran into a similar problem yesterday. I found that the RemoteLoadPath is baked into the catalog when you build the content, so no matter how you change it in editor, it will still point to the same path until you re-build it. The only way you can change the path at runtime is if you put
    {Namespace.Class.Property}
    in the RemoteLoadPath, then when you change that property in code, it will replace everything inside
    {}
    with the value that property contains.
    For example, my RemoteLoadPath is this:
    {LoL.AssetManager.AssetPath}/[BuildTarget]

    Anything inside
    {}
    is evaluated at runtime, anything inside
    []
    is evaluated when you build it.


    Code (CSharp):
    1. namespace LoL
    2. {
    3.     public static class AssetManager
    4.     {
    5.         public static string AssetPath { get; private set; } = "path/to/your/content/server";
    6.     }
    7. }
     
    liyangw107 likes this.
  3. Rob-Hafey

    Rob-Hafey

    Joined:
    Jul 24, 2014
    Posts:
    12
    Problem solved, thanks a bunch.

    To test I changed the remote load path in the profile to be invalid, rebuilt and it didn't load any more (what I expected). Then corrected the path, rebuilt and it worked (of course). And then if I changed the remote directory name to something other than the remote path it didn't load again (also expected).

    I think that what must have happened is that I made a build when it was set to default (local). I expected the path to change from only the profile switch. Nope. Only happens after a build.

    Now on to the next problem :)