Hey all! I have a bad problem with Addressables. I really can’t understand how to pre-download and cache bundles in my game, at startup. I have a loading screen before the game begins where i check for catalog updates and download bundles. It just does not work, I don’t know why.
I’ve already built and uploaded the output of the Default Build Script on my server and checked if it can serve them correctly, from browser I can download them, so it should work. The remote load path is set correctly. Am I missing something?
I’m using Unity 6.000.0.23f1 and Addressables 2.2.2.
This is the method I use to download bundles:
private IEnumerator DownloadAssetBundles()
{
// 1. check if there's any catalog to update
var checkHandle = Addressables.CheckForCatalogUpdates();
yield return checkHandle;
if (!checkHandle.IsValid())
{
Debug.LogError("Invalid handle from CheckForCatalogUpdates");
yield break;
}
if (checkHandle.Status == AsyncOperationStatus.Succeeded && checkHandle.Result.Count > 0)
{
Debug.Log("Updates available, continue with download");
// 2. update catalogs to download bundles to update
var updateHandle = Addressables.UpdateCatalogs(checkHandle.Result);
yield return updateHandle;
if (updateHandle.Status == AsyncOperationStatus.Succeeded)
{
Debug.Log("Catalogues updated");
var downloadHandle = Addressables.DownloadDependenciesAsync(checkHandle.Result);
yield return downloadHandle;
Debug.Log("Starting download");
while (!downloadHandle.IsDone)
{
_assetBundlesLoadingBar.fillAmount = downloadHandle.PercentComplete;
_assetBundlesLoadingText.text = (int)(downloadHandle.PercentComplete * 100) + "%";
yield return null;
}
if (downloadHandle.Status == AsyncOperationStatus.Succeeded)
{
Debug.Log("Download completed");
}
else
{
Debug.LogError("Error during download");
}
Addressables.Release(downloadHandle);
Addressables.Release(updateHandle);
}
else
{
Addressables.Release(updateHandle);
Debug.LogError("Error during catalogues update");
}
}
else
{
Addressables.Release(checkHandle);
Debug.Log("No updates available");
_assetBundlesLoadingBar.fillAmount = 1;
_assetBundlesLoadingText.text = "100%";
_updateEndCallback(true);
}
Addressables.Release(checkHandle);
_assetBundlesLoadingBar.fillAmount = 1;
_assetBundlesLoadingText.text = "100%";
_updateEndCallback(true);
}
Thanks in advance for help, if you need screenshots or something else I’ll upload anything needed.
The error I’m receiving is Invalid checkHandle.