Search Unity

Question Can't get DownloadDependenciesAsync to work

Discussion in 'Addressables' started by Jalict, Jun 5, 2020.

  1. Jalict

    Jalict

    Joined:
    Nov 3, 2014
    Posts:
    20
    Currently have a bunch of Addressable AssetBundles that is available from a remote location that contains a few scenes. I can load the scenes just fine using
    Addressables.LoadSceneAsync(IResourceLocation)
    and I see the caching and everything else working as intended.

    What I wanted to do now is Download the Dependencies using the same IResourceLocation before I actually switch to the scene and give the user some visual indication. In order to do so I have tried to do
    Addressables.DownloadDependenciesAsync(IResourceLocation.Dependencies)
    and then check the progress of that. The process is always immediately finished with the status Succeeded. When I debug the Dependecies I see it contains valid addresseses to the remote location. If I check the Downloadsize before trying to download the Dependecies, then it reports 0.

    I have tried clearing the locally cached bundles so that I am sure that I do not have the bundles locally stored. I am even sure of this, as whenever I then try to LoadSceneAsync using the same IResourceLocation, then it actually starts downloading the needed dependencies.

    Am I using the
    Addressables.DownloadDependenciesAsync(IResourceLocation.Dependencies)
    wrongly? I can't find any demo samples on the GitHub repository and the docs. seems to indicate that I am doing it right? I am testing from Editor with Using Existing Build option and Addressables 1.8.3
     
    Last edited: Jun 5, 2020
  2. phobos2077

    phobos2077

    Joined:
    Feb 10, 2018
    Posts:
    350
    You need to call
    Addressables.DownloadDependenciesAsync(IResourceLocation) instead because it's already getting the dependencies of the locations you're passing. In your case you're trying to download dependencies of an asset bundle which is not what you need.
     
    Jalict likes this.
  3. Jalict

    Jalict

    Joined:
    Nov 3, 2014
    Posts:
    20
    I did try that in the start and got
    Code (CSharp):
    1. Exception encountered in operation UnityEngine.ResourceManagement.ResourceManager+CompletedOperation`1[System.Collections.Generic.IList`1[UnityEngine.ResourceManagement.ResourceProviders.IAssetBundleResource]], result='', status='Failed': Exception of type 'UnityEngine.AddressableAssets.InvalidKeyException' was thrown.
    It does seem to return an actual Download size now, but now the DownloadDependenciesAsync wont work.
     
  4. Jalict

    Jalict

    Joined:
    Nov 3, 2014
    Posts:
    20
    Solved! Just had to use the IResourceLocation.PrimaryKey when you are using DownloadDependenciesAsync
    Thanks a lot for the pointer phobos2077!
     
    phobos2077 likes this.
  5. phobos2077

    phobos2077

    Joined:
    Feb 10, 2018
    Posts:
    350
    Looks like DownloadDependenciesAsync doesn't have overload that accept single IResourceLocation. Try passing the string key instead or IList<IResourceLocation>
     
    Jalict likes this.