Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved How to track download progress?

Discussion in 'Addressables' started by Jelmer123, Apr 12, 2021.

  1. Jelmer123

    Jelmer123

    Joined:
    Feb 11, 2019
    Posts:
    243
    Edit: solved, see post #2

    For my online hosted addressables I'm trying to track download progress. I'm doing the following in a coroutine but without luck:

    Code (CSharp):
    1.  
    2. AsyncOperationHandle<GameObject> handle = Addressables.LoadAssetAsync<GameObject>(assetRef);
    3. yield return handle;
    4. while (!handle.IsDone)
    5. {
    6.          Debug.Log($"Loading {handle.PercentComplete}")
    7.          yield return new WaitForSeconds(0.1f);
    8. }
    9.  
    I was hoping that handle.PercentComplete would give me downoad progress. Wrong?
     
    Last edited: Apr 12, 2021
  2. Jelmer123

    Jelmer123

    Joined:
    Feb 11, 2019
    Posts:
    243
    It appears that handle.GetDownloadStatus().Percent also exists and works. The script above had a bug because of yield return handle which stopped the script until all was finished.

    So working:

    Code (CSharp):
    1. AsyncOperationHandle<GameObject> handle = Addressables.LoadAssetAsync<GameObject>(assetRef);
    2. while (!handle.IsDone)
    3. {
    4.          Debug.Log($"Loading {handle.GetDownloadStatus().Percent}")
    5.          yield return new WaitForSeconds(0.1f);
    6. }
     
    Last edited: Apr 12, 2021
    Oxy949 likes this.
  3. Raghavendra

    Raghavendra

    Joined:
    Mar 14, 2014
    Posts:
    52
    Which version of Addressables are you using? Some of the older versions have this issue.