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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Resolved Downloading 'Fast-Follow' addressables pack always report a progress of 0. (Play Asset Delivery)

Discussion in 'Addressables' started by Phan-Phantz, May 25, 2023.

  1. Phan-Phantz

    Phan-Phantz

    Joined:
    Nov 11, 2015
    Posts:
    15
    Hi, I'm trying out the example of Addressables support for Play Asset Delivery from this official example project and encounter a problem where I cannot retrieve the download progress of 'Fast-Follow' addressable assets from the AsyncOperationHandle. It's always return "0" whether I use PercentComplete or GetDownloadStatus().

    For more context, I was packaging a video player prefab with a 120 MB video file in an Addressables Group and built it as 'Fast-Follow' asset pack using the example project above and follow the provided instructions here .

    Then I wrote a loader script that simply load the video via Addressable API and getting the download progress to display it on the text component.

    Code (CSharp):
    1. IEnumerator Start()
    2. {
    3.      var handle = Addressables.LoadAssetAsync<GameObject>("VideoPlayer");
    4.      while (!handle.IsDone)
    5.      {      
    6.          text.text = handle.GetDownloadStatus().Percent + "% (" + handle.GetDownloadStatus().DownloadedBytes + " B)";
    7.          yield return null;
    8.      }
    9.      var result = Instantiate(handle.Result);
    10.      result.transform.SetParent(transform);
    11.      result.transform.localScale = Vector3.one;
    12.      result.transform.localPosition = Vector3.zero;
    13. }
    It turns out, both Percent and DownloadedBytes always return 0 when I try out the uploaded build on my Android device. The download is working fine in the background because I was able to see the video loads up after I left the app open for a while, I just cannot retrieve the download progress to show on the UI.

    Am I doing something wrong here? Or is this an issue on the Unity side or the example project?

    Unity Version : 2021.3.2f1
    Addressables Package Version : 1.19.19
    The project is modified from this example
     
  2. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    959
    Note: If you *only* use fast-follow, don't bother with the PAD samples at all. Unity natively supports PAD fast-follow packages. To enable this, enable Build App Bundle in the build settings and Split Application Binary in the player settings, that will build an AAB with streaming assets etc. packed into fast-follow packs. This is how we distribute our game.
     
  3. Phan-Phantz

    Phan-Phantz

    Joined:
    Nov 11, 2015
    Posts:
    15
    Hi, AlkisFortuneFish. Thanks for the suggestion! This is much simpler.
     
  4. Phan-Phantz

    Phan-Phantz

    Joined:
    Nov 11, 2015
    Posts:
    15
    For the original question, I did find an alternative for Addressables support for Play Asset Delivery that I decided to use instead of the poor official PAD sample. Thanks to jelte's solution on GitHub which is much more robust and has less issues compare to the official sample.

    At first, this GitHub package also has the same problem where the download progress is always 0. But I was able to modify the code to fix this issue and create a pull request to the original repository.

    You can find my forked repo here that already applied the fix.

    To get the download progress you can now use handle.PercentComplete. I cannot properly implement a fix for GetDownloadStatus() yet but to retrieve the total download size of the remote asset packs on Google Play you can use AddressablesAssetDelivery.GetDownloadSizeAsync() from Jelte's library.