Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Help me understand addressables -- Remote Hosting

Discussion in 'Addressables' started by javierfed, Jul 25, 2019.

  1. javierfed

    javierfed

    Joined:
    Apr 10, 2015
    Posts:
    50
    I am attempting to get the addressables system up and running with our next game idea, and I am having a rough go of it and would like some help figuring out what I am doing wrong.

    first off, I am unsure if this is more of a unity answers question or a full on forum thread idea so I am just going with this for now.

    I have installed the system via Package Manager, v1.1.5. and I understand how to assign addesses, I am trying to get the bundles to allow me to load them from my online server... but this isn't working as intended... for right now I am trying to hosting this localy first...

    upload_2019-7-24_19-9-11.png

    I would think this is a pretty standard configuration... I have the addressables manager set to Packed Play mode, I click to build and the "ServerData/Android" folder gets the Remote catalog but no bundles... odd...

    running the game throws

    Exception encountered in operation UnityEngine.AddressableAssets.Initialization.InitializationOperation, result='', status='Succeeded' - Chain<IList`1,IResourceLocator>: ChainOperation of Type: System.Collections.Generic.IList`1[UnityEngine.Texture] failed because dependent operation failed
    Exception of type 'UnityEngine.AddressableAssets.InvalidKeyException' was thrown., Key=Backgrounds
    UnityEngine.ResourceManagement.ChainOperation`2:OnWrappedCompleted(AsyncOperationHandle`1)
    DelegateList`1:Invoke(AsyncOperationHandle`1) (at Library/PackageCache/com.unity.addressables@1.1.5/Runtime/ResourceManager/Util/DelegateList.cs:69)
    UnityEngine.ResourceManagement.ResourceManager:Update(Single)
    MonoBehaviourCallbackHooks:Update() (at Library/PackageCache/com.unity.addressables@1.1.5/Runtime/ResourceManager/Util/MonoBehaviourCallbackHooks.cs:19)​

    The "Backgrounds" is supposed to be the name of the group... my code for this loading looks like this

    Code (CSharp):
    1.     private IEnumerator Start()
    2.     {
    3.         controller = BCFC.instance;
    4.         Debug.Log($"Attempting to load assets");
    5.         yield return Addressables.LoadAssetsAsync<Texture>("Backgrounds", (test) =>
    6.         {
    7.             Backgrounds.Add(test);
    8.             Debug.Log($"loadedAsset: {test.name}");
    9.         });
    10.  
    11.         ActiveLayer = controller.background;
    12.     }
    I thought all of this was pretty standard but the remote aspect of it is throwing me for a loop... can anyone assist me in figuring out what is going on?
     
  2. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,091
    Click hosting -> Add and Enable a hosting service
    Change the
    RemoteLoadPath
    value to:
    http://[PrivateIpAddress]:[HostingServicePort]
     
  3. MoctezumaDev

    MoctezumaDev

    Joined:
    Aug 14, 2013
    Posts:
    53
    It is not you my friend, I think the guys from Unity need urgently to put some UX effort on this package... it's a tragedy!
     
    John1515 and booferei like this.
  4. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,091
    Sure, it is quite basic and you need to fiddle with it to understand it together with reading the manual. But as it is now, it is still somewhat simple to set it up if you know the do’s and don’ts
     
  5. MoctezumaDev

    MoctezumaDev

    Joined:
    Aug 14, 2013
    Posts:
    53
    Yeah but it's no matter of making it work, as I see it right now, I would not trust this package to handle something as critical as the downloadable content of a live game. I think the should put as much love in this package as they did with the 2D/UI features or the nested prefabs, those features got nailed right, or the post processing package, those have been nailed properly... maybe someone from the unity store comes with a better solution, I would not be surprised XD (as it never happened before)
     
    chanon81 likes this.
  6. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,091
    They did have a UI overhaul in mind somewhere but yeah its hard to create a tool that fits so many purposes.
    Asset Bundle management is not easy...
    I think they do a really great job overall. I tried making my own manager for asset bundle but it is a straight hell. Hence addressables came forth.
    I’d actually be surprised if someone would get a better job at it on the asset store as it is usually full of non optimal code. Or fits only a single purpose. Non extendable.
    Cuz thats what unity is about too.. extendability.
    I hope they’re going to use UI elements for a neater UI and give it some care. But until then having patience is key...
    The tool is working thats what counts to me. Asset bundle management is difficult and I rather have Unity take that job out of my hands than some third party asset on the store
     
  7. javierfed

    javierfed

    Joined:
    Apr 10, 2015
    Posts:
    50
    When I do this I still get the same error... if the RemoteBuildPath is set to ServerData, does the hosting service from that folder (Server Data being something they generated)... Build > Build Player Content doesn't seem to generate an asset bundle... where is the build bundles function?

    I click that function I mention and all I get is a catalog json and hash file. neither seems to have my assets.
     
  8. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,091
    ServerData is built outside of the Assets folder, one level higher than Assets.
    The Local Host needs to be enabled. Theres an Enable Service button.
    The Build > Build Player Content is the building Bundles button. Make sure you've selected the right profile in the Addressables window at the left of the window's toolbar.

    Set the remote catalog and create a new profile with the settings. (I leave my default as actual default)
    1.png

    Then select the new profile in the addressables window
    2.png

    Enable the hosting service you created under Hosting.
    3.png

    In the addressables window select Packed Mode (Note: Only works for the platform you're build on. So if you're on Windows, target the Windows platform. Bundles from Android or iOS or WebGL won't load properly in the editor when running in Packed mode.)

    4.png

    Make sure the addressable assets are set to remote build & remote load
    5.png

    And at last build the bundles using Build -> Build Playercontent (I reached my image limit x'D)
    I hope the screenshots help you.
     
  9. bfloyd

    bfloyd

    Joined:
    Dec 6, 2017
    Posts:
    9
    I ran into some of the initial issues you seem to be. The fix for creating bundles was to make sure "include in build" was selected on the remote group / schema and the asset provider was assetbundlesprovider.

    I'm still having load asset bundles (was working, now it's not because of a dependency issue), but otherwise it seems like it's building at least.
     
  10. javierfed

    javierfed

    Joined:
    Apr 10, 2015
    Posts:
    50
    I followed your advice

    So this works, somewhat... I made a profile for local online and production online (one points to a local copy of my website, where I want to eventually host the data, and the other is the configuration to actually load from my website)

    I am also building this for Android but hear me out on the compatability thing...
    If I build the content selecting my local version and then run the player in that profile version it actually loads the content and is playable. I switched to my online profile (I have not moved anything to the online server yet) and the content loads anyways! after clearing the cache and trying to run production profile the project doesn't find stuff... the difference between these profiles is just that the RemoteLoadPath for one is a local IP address (192.168.1.14:25520/[PathToData]) and the other points to my production website (www.lostseraph.com).

    the real kicker here is that if I build in the local profile, then run the project in the production profile, the project seems to assume its to load from the local profile location... ignoring the production load location... WHAT THE HECK??!
     
  11. tpvhasselmann

    tpvhasselmann

    Joined:
    Apr 23, 2018
    Posts:
    3
    Did you check folders permissions on your server to make sure you have the correct rights?
     
  12. javierfed

    javierfed

    Joined:
    Apr 10, 2015
    Posts:
    50
    I did. I do have permission to download the files from the server. the oddity that is throwing me for a loop is that if I build content with one profile, and then switch profiles, the result is the second profile being ignored and loading as if from the first profile. If I clear cache and build and load with the second program it fails to load.

    I ran more test and still that baffels me... I am curious if maybe there is a setting somewhere for using cache instead, and if I can just turn that off. I am at work right now so I can't get screenshots or explore it more.
     
  13. mekartikshah

    mekartikshah

    Joined:
    Jan 10, 2017
    Posts:
    89
    If you switch profile, you need to build it again. btw, I am also facing the same problem

    I wanted to load a scene and it's data from addressable

    If I change my RemoteBuildPath and RemoteLoadPath then it's building above my asset folder with folder name : "http:/"

    Code (CSharp):
    1. RemoteBuildPath : http://eglobal.blob.core.windows.net/modulecontainer/StandaloneOSX
    2.  
    3. RemoteLoadPath : http://eglobal.blob.core.windows.net/modulecontainer/StandaloneOSX

    but it's not loading from server instead it's loading from my local folder "http:/" i don't understand why it's not loading from my server btw, someone suggested me that after you build it as a RemoteBuild then you have to upload that Platform folder with catalog file manually to server, i tried that but i am not able to find a way to fetch it from server.
     
  14. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    Unless you have a custom build script, this won't work as a build path. We just build bundles and do normal file move stuff to put files in the build path. Our current build script cannot handle the build path being an http something.
    Uploading files is generally not as simple as knowing the path. It requires auth, and often should be wrapped in a lot of error protection. So your "RemoteBuildPath" should be some folder outside Assets, that you use as a staging folder for uploads.

    correct.
     
    mekartikshah likes this.
  15. KrikeyAdmin

    KrikeyAdmin

    Joined:
    Feb 5, 2018
    Posts:
    29
    @unity_bill
    I'm also attempting to get my Addressables hosted on google cloud CDN, but get a 'InvalidKeyException'. If I test in Editor, it loads fine in 'Fast' and 'Virtual' modes. When tested in editor with 'Packed Play Mode' or in a build on device I get this error:

    Please see the attached screenshots of my configuration to help me understand what I may have done wrong...
    Screenshot_8.png

    Screenshot_9.png Screenshot_10.png

    And finally, I attempt to Instantiate via this line of code:
    Code (CSharp):
    1. Addressables.InstantiateAsync("MyPrefabName");
    I'm running the Windows Unity Editor with Android platform.

    I'm able to publicly access / download the bundle file from my CDN, so I don't believe that is an issue.

    I've been stuck on this all day... what I am doing wrong?
     
    Claytonious likes this.
  16. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    InvalidKeyException means we couldn't find "MyPrefabName" in the catalog, which may mean we're not able to load the catalog.
    It could be related to running Android from the editor. But as long as the editor currently knows it's in Android build target, that should load the catalog. It may not render right (android shaders often won't work on windows). So in general, you are probably going to get bad results running android packed mode inside the editor, but i don't think it would lead to this exception.

    My suggestion is you set a breakpoint in InstantiateAsync inside AddressablesImpl.cs. That would help you figure out if it's finding the key. If it is a catalog loading issue, the place to set a breakpoint is in Start in ContentCatalogProvider.cs.

    You might have to import the package into your project to get breakpoints to work right. I believe in 2019.3 there's a button in package manager for that. Earlier versions require you to copy/paste the package from the package cache into <project>/Packages/com.unity.addressables/

    If you simply cannot get it to work, you can file a bug against Unity with a repro project, but since it's reliant on your actual hosting, I understand that may be tough.
     
    KrikeyAdmin and mekartikshah like this.
  17. traden

    traden

    Joined:
    Sep 16, 2009
    Posts:
    65
    I'm hitting the same exception on google cloud, but not AWS S3. I've tried everything I can think of, no luck.
     
  18. ctapp1

    ctapp1

    Joined:
    Jan 11, 2016
    Posts:
    9
    Did you figure out the issue on this? I am running into same issue, using s3

    Edit: It seems when I created a new group and moved all my assets into that one it caused all the errors. I reverted back to the default group and updated my settings through that and it worked
     
    Last edited: Oct 12, 2019
  19. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    Sounds like a few of you are having issue with google specifically. As far as I know, they don't actually host things at the raw URL. You have to use signed URLs. and you maybe need to ask google for today's URL as they move things around. We're working on a signed URL provider to help with that part of things. If it's the base URL that is changing out from under you, you need to use a runtime evaluated variable in your path {myurl} and then set that before addressables initializes.
     
  20. liyangw107

    liyangw107

    Joined:
    Aug 27, 2019
    Posts:
    12
    you need to use a runtime evaluated variable in your path {myurl} and then set that before addressables initializes.

    Yes. it is working one time.
    @unity_bill I wanted to set remote load path again after initialize but it was not applied.
    There is no solution?;)
     
  21. EmilieCollard191

    EmilieCollard191

    Joined:
    May 8, 2019
    Posts:
    77
    @unity_bill Any update on this? In our app we use a backup server if the main one is not reachable. This runtime evaluated variable can change at anytime during a session.
     
  22. nakiks

    nakiks

    Joined:
    Dec 4, 2011
    Posts:
    24
    I think this is the worst experience I've had so far using Unity3d. You need to be the least an expert on it the moment you start using it. Back to bundles...
     
    Bentoon likes this.
  23. EmilieCollard191

    EmilieCollard191

    Joined:
    May 8, 2019
    Posts:
    77
  24. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,816
    Howdy all! I'm chasing down an update on this from the team. Hang tight. :)
     
  25. andymilsom

    andymilsom

    Unity Technologies

    Joined:
    Mar 2, 2016
    Posts:
    294
    Emilie has the right method with TransformInternalId.
    This will allow you to modify a url string however you need. Note that the loadPath in the group, is appended with the bundle filename. You may need to manipulate the url in different ways such as removing the name. Depending on the final url requirements.
     
  26. Bentoon

    Bentoon

    Joined:
    Apr 26, 2013
    Posts:
    98
    Hi all,
    I'm trying to work with addressables and I have parsed an ok workflow but am having some trouble: specifically, w WebGL builds & loading remote scenes from a server

    1. I think loading Scenes Additively may be the best option for me to assemble a variety of assets together w dependencies...

    Here is my (somewhat working) workflow:
    a) import addressables package and make new group (I call 'scenes') and drag the scenes I want to load inside- Note that alone makes them addressable
    - and because it's a scene I don't think I also need to include the prefabs/ models / materials & textures... However, I believe it will help with loading if do this

    b) I set up another profile I point to a server I control the permissions on and right click to set as the active profile
    - & I make sure all my groups point to using the remotes Load and Build
    - & check the √ build remote catalog button in the Addressableasset settings also

    c) in my Starting (almost blank) scene, I have a script to load a remote addressable (below)
    Code (CSharp):
    1.     [SerializeField] AssetReference assetReferenceScene;
    2.  
    3.  
    4.     void OnSomething()
    5.     {
    6.               assetReferenceScene.LoadSceneAsync(UnityEngine.SceneManagement.LoadSceneMode.Additive);
    7.  
    8.     }

    - I test it in the Play mode (use asset database)
    - Then I use the addressables build to build (new build > default) the remote assets to my "Server Data" folder created outside the Assets folder (n my case this is a webGL build, so it creates a webGL folder to hold my bundles .json and hash)
    - After that builds I upload the (WebGL) folder to the remote server (the same file path as the remote setting I provided (above where WebGL is [build target])) & I change the permissions to be completely open so they can be accessed.
    - I test it again in addressable Play mode (with use existing build) selected as this will pull the assets remotely




    Works in Unity addressable play modes
    But Not in Browser

    Is it the WebGL?
    What am I missing?
    Thanks in advance!
    ~b
     
    Last edited: Jun 19, 2021