Search Unity

How to pre-download server contents?

Discussion in 'Addressables' started by Mr_TZ, Jan 28, 2020.

  1. Mr_TZ

    Mr_TZ

    Joined:
    Apr 5, 2018
    Posts:
    12
    If i mark all assets as remote assets?
    How to pre-download when user opens the game first time?
     
  2. supersolid-jelte

    supersolid-jelte

    Joined:
    Dec 3, 2018
    Posts:
    22
    What I did was tag (one/some) assets in each bundle I want predownloaded and use

    Code (CSharp):
    1. Addressables.DownloadDependenciesAsync("default");
    during loading.

    you can use the AsyncOperationHandle to show a download/loading bar.
     
    tiernan-costain likes this.
  3. Mr_TZ

    Mr_TZ

    Joined:
    Apr 5, 2018
    Posts:
    12
    Thank you!
    I willl have a try then.
    The document is so simple though the addresables is a complex system!
     
  4. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,123
    What if we do not want to tag all of our assets as 'default' for the sake of being able to download them? There must be a function to just a 'download all missing data'?
     
  5. LilMako17

    LilMako17

    Joined:
    Apr 10, 2019
    Posts:
    43
    DownloadDependenciesAsync() can take a list of keys as parameters. you can get all keys from your catalog with the function
    Addressables.ResourceLocators.SelectMany(x => x.Keys).ToList();
    and pass that to DownloadDependenciesAsync to download everything. passing keys of things that are already cached will just result in a no-op. Bonus: you can also pass your list of all keys to Addressables.GetDownloadSizeAsync() which will return you how many bytes DownloadDependenciesAsync will need to download (will be 0 if everything is cached already)
     
    grunt18 and Prodigga like this.