Search Unity

[0.7.4] Addressables.DownloadDependencies: PercentComplete always returns 0

Discussion in 'Addressables' started by TobiasW, Apr 25, 2019.

  1. TobiasW

    TobiasW

    Joined:
    Jun 18, 2011
    Posts:
    78
    Hello,

    I've upgraded from 0.6.8 to 0.7.4 to get an Addressables.GetDownloadSize() that takes already cached AssetBundles into account (which works, hurray), but now the following code displays 0 every frame until it's done:

    Code (CSharp):
    1.  
    2. var downloadDependenciesOp = Addressables.DownloadDependencies(label.labelString);
    3. while (!downloadDependenciesOp.IsDone)
    4. {
    5.      Debug.Log(downloadDependenciesOp.PercentComplete);
    6.      yield return null;
    7. }
    8.  
    9. Debug.Log("Done!");
    10. }
    This was working with 0.6.8.
     
    CharBodman likes this.
  2. unity_bill

    unity_bill

    Unity Technologies

    Joined:
    Apr 11, 2017
    Posts:
    954
    we'll look into it. thanks.
     
  3. unity_bill

    unity_bill

    Unity Technologies

    Joined:
    Apr 11, 2017
    Posts:
    954
    Just to double check, you are doing this in a player (not in the editor) and the bundles are up on some server, right? And the `Debug.Log(downloadDependenciesOp.PercentComplete);` gets called many times?
     
  4. TobiasW

    TobiasW

    Joined:
    Jun 18, 2011
    Posts:
    78
    This is happening both in the editor and the Android player if I remember correctly, and the bundles are indeed up on some server. The exact same code was printing proper percentages with 0.6.8, so you can (probably) rest assured that the code is working correctly.

    And I should've specified: This is part of a coroutine. So yes, "Debug.Log(downloadDependenciesOp.PercentComplete);" gets called many times (and prints 0 every time until the whole operation is done).
     
    CharBodman likes this.
  5. unity_bill

    unity_bill

    Unity Technologies

    Joined:
    Apr 11, 2017
    Posts:
    954
    Got it, just had to check :)
     
    CharBodman and TobiasW like this.
  6. David_GameDev

    David_GameDev

    Joined:
    Dec 25, 2016
    Posts:
    23
    Still seems to be a problem with 1.1.4
     
    CharBodman and fabioColombini like this.
  7. wangyucheng1992

    wangyucheng1992

    Joined:
    Feb 19, 2019
    Posts:
    52
  8. fabioColombini

    fabioColombini

    Joined:
    Dec 9, 2013
    Posts:
    18
    Yes @David_GameDev and @unity_bill
    same for me v1.1.4.

    • Scene "Main" is in a server remotly.
    • Play Mode Script = Packed Play Mode
    The scene takes a time to be loaded and just "0" are showed.

    My example:
    Code (csharp):
    1. IEnumerator LoadMainScene()
    2.     {
    3.         AsyncOperationHandle<SceneInstance> tmp = Addressables.LoadSceneAsync("Main");
    4.         tmp.Completed += OnLoadSceneCompleted;
    5.  
    6.         while (!tmp.IsDone)
    7.         {
    8.             print("Update: " + tmp.PercentComplete);
    9.             yield return null;
    10.         }
    11.     }
     
    CharBodman and David_GameDev like this.
  9. CristianGarciaJ

    CristianGarciaJ

    Joined:
    Apr 13, 2018
    Posts:
    8
    Hi everybody,

    A workaround that works for me is:


    operation.GetDependencies(deps);

    float percentComplete = 0;

    for (int i = 0; i < deps.Count; ++i)
    {
    percentComplete += deps.PercentComplete;
    }

    percentComplete /= deps.Count;

    Cheers!
     
    David_GameDev likes this.
  10. CharBodman

    CharBodman

    Joined:
    Sep 20, 2018
    Posts:
    28
    Where are you getting deps?
     
    David_GameDev likes this.
  11. CristianGarciaJ

    CristianGarciaJ

    Joined:
    Apr 13, 2018
    Posts:
    8
    From the AsyncOperationHandle
     
    David_GameDev likes this.
  12. fabioColombini

    fabioColombini

    Joined:
    Dec 9, 2013
    Posts:
    18
    @CristianGarciaJ could you explain this line in more detail?

    operation.GetDependencies(deps);
     
    David_GameDev likes this.
  13. faolad

    faolad

    Joined:
    Jan 27, 2013
    Posts:
    60
    I think this is more clear:
    Code (CSharp):
    1.   private static float calculatePercentComplete(AsyncOperationHandle asyncOperation)
    2.         {
    3.             var deps = new List<AsyncOperationHandle>();
    4.             asyncOperation.GetDependencies(deps); // deps is added to! (weird API...)
    5.             float percentCompleteSum = 0;
    6.             foreach (var asyncOperationHandle in deps)
    7.             {
    8.                 percentCompleteSum += asyncOperationHandle.PercentComplete;
    9.             }
    10.             return percentCompleteSum / deps.Count;
    11.         }
     
    fabioColombini and David_GameDev like this.
  14. CristianGarciaJ

    CristianGarciaJ

    Joined:
    Apr 13, 2018
    Posts:
    8
    Yes, the response of faolad is correct.

    Sorry for the misunderstanding :)
     
    David_GameDev likes this.
  15. CharBodman

    CharBodman

    Joined:
    Sep 20, 2018
    Posts:
    28
    Unfortunately this is still broken in 1.1.5.


    I believe this will always return 1 if you use a single label to load multiple dependencies.
    I'm going to have to test it some more.
     
  16. AndersonDev

    AndersonDev

    Joined:
    Dec 13, 2015
    Posts:
    87
    The same, operation should return progress of all dependencies.
     
  17. Favo-Yang

    Favo-Yang

    Joined:
    Apr 4, 2011
    Posts:
    311
    Report a bug please. Unity has a team helps reproduce bug, and then goes into their internal progress quickly.

    Forum is also helpful for discussion and avoiding duplicated report though.
     
    unity_bill likes this.