Search Unity

(Case 1129109) Addressables.LoadAssets<T> never completes

Discussion in 'Addressables' started by MNNoxMortem, Feb 19, 2019.

  1. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    723
    Hi!

    Addressables.LoadAssets does never complete for us. Neither loadOperation.IsCompleted, loadOperation.IsCanceled nor loadOperation.IsFaulted will ever become true and as the only callback that is provided is called for each and every asset there is no way to find out if it ever finishes?

    The callback gets called for every assets under the "Prefabs" tagged group but it never completes.

    Code (CSharp):
    1. public IEnumerator Coroutine(){
    2.   var loadOperation = Addressables.LoadAssets<GameObject>("Prefabs", Callback);
    3.   while(!loadOperation.IsCompleted && !loadOperation.IsCanceled && !loadOperation.Faulted)
    4.     yield return null;// Never finishes
    5. }
    6.  
    7. public void Callback(IAsyncOperation<GameObject> op){
    8.   if(op.Result == null) return;
    9.   Debug.Log(op.Result.name);
    10. }
    Edit: Found a workaround using Closures

    Code (CSharp):
    1. public IEnumerator Coroutine(){
    2.   var loadingOperation = Addressables.LoadAsset<GameObject>("Prefabs",null);
    3.   loadingOperation.Completed += x => isLoading = false;
    4.   while (isLoading)
    5.     yield return null;//Finishes.
    6.   Debug.Log("Done");
    7. }
     
    Last edited: Feb 19, 2019