Search Unity

How to pre-download asset bundles ?

Discussion in 'Addressables' started by BrokenAngel, Dec 6, 2019.

  1. BrokenAngel

    BrokenAngel

    Joined:
    Mar 24, 2013
    Posts:
    92
    Hello guys , I'm new to Addressable system and I have a little confusing when using it.

    So I have build the assets into asset bundle ( including content catalog .hash and .json ).

    Now at client I'm doing something like this

    Code (CSharp):
    1. private IEnumerator LoadAssetBundles()
    2.         {
    3.             _loadABDone = false;
    4.             var initOp = Addressables.InitializeAsync();
    5.             initOp.Completed += AssetBundle_InitComplete;
    6.  
    7.             yield return new WaitUntil(() => _loadABDone);
    8.         }
    9.  
    10.         private void AssetBundle_InitComplete(AsyncOperationHandle<IResourceLocator> obj)
    11.         {
    12.             var loadCatalog = Addressables.GetDownloadSizeAsync(obj.Result.Keys);
    13.             loadCatalog.Completed += LoadCatalog_Completed;
    14.         }
    But the system return

    Code (CSharp):
    1. Exception encountered in operation UnityEngine.ResourceManagement.ResourceManager+CompletedOperation`1[System.Int64], result='', status='Failed': Exception of type 'UnityEngine.AddressableAssets.InvalidKeyException' was thrown.,
    So when I log all the keys name its seem wilds ( there is number, hash , scene name , resources at Resources folder, etc...)

    Is there a way I can get all the files I need to downloaded from my server and pre-load them correctly ?

    Thanks.