Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. We are looking for your feedback about Templates! Tell us about your experiences by taking our survey.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

loading another project's catalog

Discussion in 'Addressables' started by Arcanor, Apr 15, 2020.

  1. Arcanor

    Arcanor

    Joined:
    Nov 4, 2009
    Posts:
    277
    I have created two Unity projects. A CLIENT project, and a CONTENT project. My goal is to be able to author content in the CONTENT project, and then consume that content from my CLIENT application.

    In my CLIENT project, I've defined a Local addressable group, as well as a Remote group (which I'm accessing through http://localhost, served up via XAMPP). Then I do a build->new build->default build script, and copy the resulting files into the web folder. So far, all is good. I can LoadAssetAsync, no problems.

    In my CONTENT project, I set the groups up identically to the client. Then I do a build->new build->default build script, and copy the resulting files into the web folder, right on top of the ones already there from the client.

    When I request an asset that was authored in my CONTENT project, the CLIENT doesn't see or load it.

    How do I get my CLIENT to look at and consume the catalog and assets that were generated by the CONTENT project, and then placed in the same location?
     
  2. Thom_Denick

    Thom_Denick

    Joined:
    May 19, 2014
    Posts:
    12
    You need to load content in via a Catalog. So you use LoadContentCatalogAsync. All of the files are hashed and such, so I'm fairly certain you can't just overwrite them, they won't have the correct hash. You should post your errors here when you attempt to load, would be clearer what's going on.
     
  3. Arcanor

    Arcanor

    Joined:
    Nov 4, 2009
    Posts:
    277
    Not getting any errors with my original approach. Just no assets.

    I will give a longer look at LoadContentCatalogAsync and see what I can see. Thanks for the tip!
     
  4. CameronND

    CameronND

    Joined:
    Oct 2, 2018
    Posts:
    49
    I am working on a project with a large amount of content which we will eventually need to migrate to a similar multi-project approach. I'd love to hear back from you if/how you got it all to work.
     
  5. Arcanor

    Arcanor

    Joined:
    Nov 4, 2009
    Posts:
    277
    After some testing, I'm not sure that LoadContentCatalogAsync is what I need here. It needs a PATH argument, and when I put in, i.e. "http://localhost/mystuff/StandaloneWindows64/", it comes back with Status "Failed", even if that URL works fine in my browser, and shows the asset files that I want.

    Is LoadContentCatalogAsync only useful for LOCAL hard drive resources, and not web URLs?

    Perhaps I need LoadResourceLocationsAsync instead? I will do some testing on this.
     
  6. Arcanor

    Arcanor

    Joined:
    Nov 4, 2009
    Posts:
    277
    I'm using LoadResourceLocationsAsync and the client is again only finding its own (remote) catalog, and ignoring the other catalog and assets created by the CONTENT project. There must be a way to either have the client consume all the different catalogs present, or maybe there's something I need to do to merge the catalogs somehow?

    As an experiment, I copied the Assets/AddressableAssetsData/Windows/addressables_content_state.bin from the CLIENT project into the CONTENT project, and then did Build->Update a previous build from within the CONTENT project. Then I ran the CLIENT app again and it was able to see the CONTENT content, but not the CLIENT content. So apparently the build simply replaced the catalog info that was there. I guess this is progress, so yay? But I still don't know how to build and deploy new content without overwriting any content created in a different project.

    Need a way to merge catalogs. Or tell the client to consume catalogs from multiple addressables_content_state.bin.
     
  7. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    476
    What was the error?
     
  8. Arcanor

    Arcanor

    Joined:
    Nov 4, 2009
    Posts:
    277
    System.Exception: ChainOperation of Type: UnityEngine.AddressableAssets.ResourceLocators.IResourceLocator failed because dependent operation failed
    ChainOperation of Type: UnityEngine.AddressableAssets.ResourceLocators.IResourceLocator failed because dependent operation failed
    Failed to load content catalog.
    UnityEngine.Debug:Log(Object)
    <>c:<LoadCatalog>b__3_1(AsyncOperationHandle`1) (at Assets/_ASoM/Scripts/LoadAssetsFromRemote.cs:49)
    DelegateList`1:Invoke(AsyncOperationHandle`1) (at Library/PackageCache/com.unity.addressables@1.7.5/Runtime/ResourceManager/Util/DelegateList.cs:69)
    UnityEngine.ResourceManagement.ResourceManager:Update(Single)
    MonoBehaviourCallbackHooks:Update() (at Library/PackageCache/com.unity.addressables@1.7.5/Runtime/ResourceManager/Util/MonoBehaviourCallbackHooks.cs:19)


    Are you suggesting that LoadContentCatalogAsync can be used for remote catalogs via http?
     
  9. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    476
    That error doesn't seem very useful. Did you not have other error logs? I usually see 3 or 4 errors when I have an issue, and one of them is the real error.

    I haven't tried it myself, but I believe that should be the case. I've seen other people do it that way.
     
  10. Arcanor

    Arcanor

    Joined:
    Nov 4, 2009
    Posts:
    277
    Nope. This is a small test project. Even that error was a Debug.Log that I put in just to see the AsyncOperationHandle.OperationException returned by LoadContentCatalogAsync. There are literally no errors.
     
  11. Arcanor

    Arcanor

    Joined:
    Nov 4, 2009
    Posts:
    277
    Regarding LoadContentCatalogAsync, I am getting no errors (same exception output as above) even if I put in a bogus URL string. i.e. my "real" string should be http://localhost/ASoM/StandaloneWindows64/, but I get the same output if I change it to http://localhost0/ASoM/StandaloneWindows64/, although it does take a second for the localhost0 to timeout. But still, no errors other than the exception as above.

    So apparently LoadContentCatalogAsync fails silently and doesn't offer any help to diagnose the problem. Perhaps this is something that could be improved in a future release?
     
  12. Arcanor

    Arcanor

    Joined:
    Nov 4, 2009
    Posts:
    277
    Okay, apart from LoadContentCatalogAsync failing silently, I may have discovered the real reason why it's actually failing. I didn't realize I need the name of the json file as well, and not just the folder that it's in. So, like this: "http://localhost/ASoM/StandaloneWindows64/catalog_2020.04.16.15.34.47.json".

    So if I need to put the unique identifier into my application code, how will that work in the real world, when I'm doing content updates? Is that catalog name never going to change? Obviously, I wouldn't want to have to send a whole new application EXE if the content address changes.
     
  13. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    476
    You might need to enable
    Log Runtime Exceptions
    in your addressable settings.

    You could have your server send you the path to the new catalog. Or you can update existing without re-building everything.
     
  14. Arcanor

    Arcanor

    Joined:
    Nov 4, 2009
    Posts:
    277
    I did already have that set during testing. Didn't say anything.

    How would I have my server send the catalog path? So far I've been looking at this from the client side.
     
  15. ImpossibleRobert

    ImpossibleRobert

    Joined:
    Oct 10, 2013
    Posts:
    345
    Hi @Arcanor, were you ever able to get it running? I am working on a similar client/content model right now and I am stuck at a very similar point in time. I can successfully load all my catalogs with

    AsyncOperationHandle<IResourceLocator> handle = Addressables.LoadContentCatalogAsync(path to json)

    and the handle.Result contains the correct keys. But I am wondering, what happens NOW? Will the addressables do their magic now automatically? Or do I need to put the result somewhere and merge it into a central catalog? @unity_bill can you shed some light here? Would be highly appreciated. In my use case, I have 4 remote catalogs and want them all being accessible in one application.

    And yes, I'd also want to have stable names for the json files. What I will most likely do is have a post-processor that renames the files before uploading.
     
  16. Tayfe

    Tayfe

    Joined:
    Nov 21, 2011
    Posts:
    78
    Take a look at my thread for a detailed solution: https://forum.unity.com/threads/download-and-save-external-content-catalog.833023/

    Now that all keys are stored in the stack you can use
    LoadResourceLocation()
    and then load your content with
    LoadSceneAsync()
    or
    LoadAssetAsync()
    .

    If you build 4 catalogs and you update those four their names will be stable. Just use "Build->Update a previous Build" and your new catalog files (.json and .hash) will have the same names as before. Just their content changes and new bundle files might be added. So there is no need to change the URL to the catalog file.
     
  17. ImpossibleRobert

    ImpossibleRobert

    Joined:
    Oct 10, 2013
    Posts:
    345
    Thanks a lot! I also figures it out in the meantime. Calling LoadContentCatalogAsync 4 times is actually enough. Afterwards LoadAssetAsync works as expected. The only issue I am still fighting with is the shaders issue, that others also discribed in the forums, that when multiple bundles refer to the same (e.g. standard) shader, errors are thrown. It would be great if the addressables system could handle such duplications that I can do nothing against (since any user could upload something, unaware of everything else) somehow more gracefully.
     
  18. Tayfe

    Tayfe

    Joined:
    Nov 21, 2011
    Posts:
    78
    Your welcome!

    I'm not sure whether I get you right and maybe your problem is another one. But you could try this:

    As far as I understood does
    LoadContentCatalogAsync()
    just add everything onto some stack which can cause problems. I solved this problem by simply calling
    ClearResourceLocators()
    everytime before I load another catalog. But this does of course only work because I don't need to load more then one catalog at a time.
     
    ImpossibleRobert likes this.
unityunity