Addressables.LoadAssetAsync WaitForCompletion error “Reentering the Update method is not allowed.”

What Im doing:

        var handle = Addressables.LoadAssetAsync<T>( assetPath );
        result = handle.WaitForCompletion();
        handle.ReleaseHandle();

What the error says:
Exception: Reentering the Update method is not allowed. This can happen when calling WaitForCompletion on an operation while inside of a callback.
UnityEngine.ResourceManagement.ResourceManager.Update

But these codes are not inside of a callback.
Further more, when I did something similar with Addressables.LoadSceneAsync and WaitForCompletion, every thing is ok.

So what’s wrong?

OK, I found out what’s wrong. It’s not directly inside of a callback, but the callback is outside of serveral layers.:face_with_spiral_eyes:

No, I am mad about this…

    async void AsyncLoad() {
        Debug.Log( $"Begin AsyncLoad" );
        //var a = await Addressables.LoadAssetAsync<GameObject>( "Sword Icon.prefab" ).Task;  //this is good
        var a = await Addressables.LoadSceneAsync( "UITestStart.unity" ).Task;  // this is wrong!
        SyncLoad();
        //a.Instantiate();
        Debug.Log( $"After AsyncLoad  {a}" );
    }


    void SyncLoad() {
        var handle = Addressables.LoadAssetAsync<GameObject>( "Sword Icon.prefab" );
        handle.WaitForCompletion();
        handle.Result.Instantiate();
        Debug.Log( $"SyncLoaded: Sword  {handle.Result.name}" );
    }

If use await LoadSceneAsync before WaitForCompletion, still get the error:
Exception: Reentering the Update method is not allowed. This can happen when calling WaitForCompletion on an operation while inside of a callback.

What callback is in await ??? Why LoadAssetAsync is Ok ???

I gave up, change to return handle as IEnumerator + Coroutine instead, problem solved:roll_eyes: