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

Question Download all assets

Discussion in 'Addressables' started by RoyZeng, May 21, 2020.

  1. RoyZeng

    RoyZeng

    Joined:
    Dec 24, 2019
    Posts:
    9
    Hi,

    Is there a way to get all assets download size and download all dependencies without parsing key?

    Thanks.
     
    Last edited: May 21, 2020
  2. HugoClip

    HugoClip

    Joined:
    Feb 28, 2018
    Posts:
    52
    This could work for downloading all remote bundles.
    Code (CSharp):
    1.            
    2. ResourceLocationMap locMap = ResourceLocators.First(locator => locator is ResourceLocationMap) as ResourceLocationMap;
    3.  IEnumerable<IResourceLocation> remoteLocations = locMap.Locations.Select(kv => kv.Value).SelectMany(loc => loc)
    4.                 .Where(loc2 => ResourceManagerConfig.ShouldPathUseWebRequest(loc2.InternalId));
    5.            
    6. Addressables.DownloadDependenciesAsync(remoteLocations);
     
  3. RoyZeng

    RoyZeng

    Joined:
    Dec 24, 2019
    Posts:
    9
    Thanks for the reply.

    I use the same way to GetDownloadSize but it returns 0.

    Does it need to use another way to get all asset download size?
     
  4. RoyZeng

    RoyZeng

    Joined:
    Dec 24, 2019
    Posts:
    9
    Hi,I found the reason is the remoteLocations do not have dependencies.
    In the AddressablesImpl.GetDownloadSizeAsync and AddressablesImpl.DownloadDependenciesAsync.
    The locHash add the IResourceLocation's Dependencies but do not add the IResourceLocation which I parse into.
    I use Where(loc => loc.HasDependencies) instead.