I have two projects, a main player and a content project.
I am building bundles in the content project and loading them in the player project by using: Addressables.LoadContentCatalogAsync(catalogURL); then loading the assets.
This works fine with a connection to the server, but I would like to implement an offline mode where after the bundles are downloaded the first time, you don’t need a connection in the future to load the assets.
Currently it gives an invalid key exception when offline since the catalog isn’t loaded.
Is it possible to cache the external catalog in the addressables system currently, or will I have to manually download the catalog locally and point the url to it when offline?
You can add a resource locator directly. Though Addressables.AddResourceLocator()
// Pseudo code, not actual working code
var catalogData = new ContentCatalogData(data)
ResourceLocationMap locMap = catalogData.CreateLocator(providerSuffix);
addressables.AddResourceLocator(locMap, catalogData.localHash, catalogData.location);
/// <summary>
/// Add a resource locator.
/// </summary>
/// <param name="locator">The locator object.</param>
/// <param name="localCatalogHash">The hash of the local catalog. This can be null if the catalog cannot be updated.</param>
/// <param name="remoteCatalogLocation">The location of the remote catalog. This can be null if the catalog cannot be updated.</param>
public static void AddResourceLocator(IResourceLocator locator, string localCatalogHash = null, IResourceLocation remoteCatalogLocation = null)
{
m_Addressables.AddResourceLocator(locator, localCatalogHash, remoteCatalogLocation);
}