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

Content Catalog loading issues

Discussion in 'Addressables' started by NinjaDanzer, Sep 5, 2020.

  1. NinjaDanzer

    NinjaDanzer

    Joined:
    Jan 24, 2019
    Posts:
    7
    Hi there!
    I just want to make something really simple.
    Build an asset catalog from one project, and then import it in another, instantiate a prefab defined in said catalog.
    Now, according to the documentation, it should be just calling Addressables.LoadContentCatalogAsync("URL_TO_CATALOG.json", true), as this snippet suggests:
    No further action is required to load the content catalog once the operation completes.
    and
    Like with the LoadContentCatalogAsync API, no further action is needed to use the new content catalogs.

    I interpret this to mean that as soon as the async operation is complete, I can call (as an example) Addressables.Instantiate("AddressableKey").

    However, the system does not seem to be able to find the key, throwing an UnityEngine.AddressableAssets.InvalidKeyException.

    I must be missing something with this, it might be that I need to do something with the result from the async operation, which is an IResourceLocator wrapped in an AsyncOperationHandle.
    Accessing Result.keys gives me several strings, some seem to be a name of bundles (myreallycoolremoteassets_assets_all_100f38b5cd3fb318428370fd918df61f.bundle), a material (SphereMaterial.mat), along those lines.

    Now, that is the main problem, the second is that I am actually cheating and placing the built catalog directly to where it would be cached on disk, so somewhere in LocalLow on my windows environment.
    When I try to actually access the content catalog from a python webserver I have running locally I get the following error message:

    Exception encountered in operation Resource<Object>(catalog_2020.09.05.12.33.05.hash), status=Failed, result= : Invalid path in TextDataProvider : 'PATH_TO_MY_USER_FOLDER/LocalLow/DefaultCompany/TestRemoteAddressablesLoader/com.unity.addressables/catalog_2020.09.05.12.33.05.hash'.
    UnityEngine.AddressableAssets.Addressables:LoadContentCatalogAsync(String, Boolean, String)
    <Start>d__1:MoveNext() (at Assets/Scripts/Loader.cs:17)
    System.Runtime.CompilerServices.AsyncVoidMethodBuilder:Start(<Start>d__1&)
    Loader:Start()

    So it seems that it's still trying to access the cached data for some reason, maybe I need to call some cleaning method or other to ensure that the content catalog is correctly downloaded.

    I've already read the following topic but still can't firmly grasp any real headway through it.
    https://forum.unity.com/threads/modding-with-addressables.539926/

    I could not really find any good answers in the documentation, so I turn to the good people of this forum and ask if anyone could shed any light on this topic, thanks for giving it a read at least!
     
    Mikael-H likes this.
  2. Mikael-H

    Mikael-H

    Joined:
    Apr 26, 2013
    Posts:
    309
    I am also interested in this. Maybe @unity_bill could enlighten us? :)
     
  3. Tayfe

    Tayfe

    Joined:
    Nov 21, 2011
    Posts:
    103
    Some weeks have already been passed since I've dealt with addressables the last time so I'm currently not completly in the topic anymore. But I guess what you are missing here is
    Addressables.LoadResourceLocationsAsync(object key)
    between loading content catalog and initializing. Just pass a string with the name of the object you want to load and wait for it to finish. Then you should be able to use
    Addressables.Instantiate()
    .
     
    Mikael-H likes this.
  4. NinjaDanzer

    NinjaDanzer

    Joined:
    Jan 24, 2019
    Posts:
    7
    Thanks for the advice @Tayfe!
    Tested it out by iterating over the keys in the locator returned from running
    Code (CSharp):
    1. Addressables.LoadContentCatalogAsync(...)
    But it didn't work, throwing the following error when trying to instantiate:

    Exception encountered in operation Resource<IAssetBundleResource>(myreallycoolremoteassets_assets_all_100f38b5cd3fb318428370fd918df61f.bundle), status=Failed, result= : Invalid path in AssetBundleProvider: 'ServerData/StandaloneWindows/myreallycoolremoteassets_assets_all_100f38b5cd3fb318428370fd918df61f.bundle'.
    UnityEngine.AddressableAssets.Addressables:InstantiateAsync(Object, Transform, Boolean, Boolean)
    Loader:Update() (at Assets/Scripts/Loader.cs:71)


    I also got a bit into trying using Hosting Services instead, might be what I am looking for but I haven't been able to reliably load new bundled assets on a client.
     
  5. NinjaDanzer

    NinjaDanzer

    Joined:
    Jan 24, 2019
    Posts:
    7
    Managed to get it working with Hosting Services.
    For anyone reading this, just follow the Hosting Services guide on the addressables manual, and when building your content make sure that you ALWAYS hit the "Update a previous build" button, anything else will mess up your content delivery.