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.
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 ???