Getting LocalizedString from addressable scriptable object

Hi all !

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 ?

Thanks !

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.

Well, the async version actually never fires the Completed event.

Logging its progress and result on the Update lifecycle event shows that its progress is stuck at 0%…

Looks like i miss something, or my configuration is buggy ?

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.

i’m already on 1.4.4 for localization package.
addressable package (previously installed) is in version 1.21.17

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.

Anyway, thanks for your help Karl !

Did you build the addressables data for the player?
https://docs.unity3d.com/Packages/com.unity.localization@1.4/manual/QuickStartGuideWithVariants.html#preview-and-configure-your-build

Can you share the project so I can see whats going wrong?