I wanted to load a localizedString from a scriptableObject loaded as a an addressable from code but ran into an exception:
Exception: Reentering the Update method is not allowed. This can happen when calling WaitForCompletion on an operation while inside of a callback.
This is the code i used:
var a = anAssetReference.LoadAssetAsync();
a.Completed += (handle) =>
{
Debug.Log("Completed loading asset");
// Here description is a LocalizedAsset.
var b = handle.Result.description.GetLocalizedString();
};
So, what would be the correct workflow for my use case ?
The problem here is that GetLocalizedString calls WaitForCompletion and you can not do that inside of an addressables callback.
Can you use the asynchronous version instead? GetLocalizedStringAsync.
What version of the package are you using? Try updating to 1.4.4. If it’s not visible in the package manager you can edit the manifest.json file in the package folder.
Which async event is not being fired?
anAssetReference? The error you are getting is caused by calling WaitForCompletion inside of an addressables callback. If it’s not being triggered by the completed event in the code you showed then it must be coming from another part. Do you have any other addressables loading?
I tried a simple case where i load a LocalizedString which is directly associated to the same Gameobject.
The sync and async both work well on editor, but that never worked from a build. I’m giving up as i already spent a lot of hours into this, reinstalling, reconfiguring, experimenting. My needs being simple, i’ll make a custom system.