How to avoid Reentering the Update method is not allowed in following case using localizaiton package

Hi there,

On scene async Awake (all by awaiting),
I first SelectLocale, then await for SelectedLocaleAsync, then I GetValue and this error happens, I think it happend on device build after i disabled preloading.
So my question is even if i wait for selectedLocaleAsync to cmplete, do i need to seperately looad all the tables? If Yes, how do i load all the tables (without hardcoding table names etc) of that language so i can add this additional step if thats the cause of issue.
Or is it better to enable preloading again?
Please advise

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 (System.Single unscaledDeltaTime) (at <00000000000000000000000000000000>:0)
UnityEngine.ResourceManagement.AsyncOperations.ProviderOperation`1[TObject].InvokeWaitForCompletion () (at <00000000000000000000000000000000>:0)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].WaitForCompletion () (at <00000000000000000000000000000000>:0)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle.WaitForCompletion () (at <00000000000000000000000000000000>:0)
UnityEngine.ResourceManagement.AsyncOperations.GroupOperation.InvokeWaitForCompletion () (at <00000000000000000000000000000000>:0)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].WaitForCompletion () (at <00000000000000000000000000000000>:0)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[TObject].WaitForCompletion () (at <00000000000000000000000000000000>:0)
UnityEngine.ResourceManagement.AsyncOperations.ProviderOperation`1[TObject].InvokeWaitForCompletion () (at <00000000000000000000000000000000>:0)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].WaitForCompletion () (at <00000000000000000000000000000000>:0)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle.WaitForCompletion () (at <00000000000000000000000000000000>:0)
UnityEngine.Localization.Operations.WaitForCurrentOperationAsyncOperationBase`1[TObject].InvokeWaitForCompletion () (at <00000000000000000000000000000000>:0)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].WaitForCompletion () (at <00000000000000000000000000000000>:0)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle.WaitForCompletion () (at <00000000000000000000000000000000>:0)
UnityEngine.Localization.Operations.WaitForCurrentOperationAsyncOperationBase`1[TObject].InvokeWaitForCompletion () (at <00000000000000000000000000000000>:0)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].WaitForCompletion () (at <00000000000000000000000000000000>:0)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[TObject].WaitForCompletion () (at <00000000000000000000000000000000>:0)
UnityEngine.Localization.Settings.LocalizedDatabase`2[TTable,TEntry].GetTableEntry (UnityEngine.Localization.Tables.TableReference tableReference, UnityEngine.Localization.Tables.TableEntryReference tableEntryReference, UnityEngine.Localization.Locale locale, UnityEngine.Localization.Settings.FallbackBehavior fallbackBehavior) (at <00000000000000000000000000000000>:0)
LocalizationManagerUnity.GetValueRaw (System.String table, System.String value) (at <00000000000000000000000000000000>:0)
Localization.LocalizationManager.GetValue (System.String table, System.String value) (at <00000000000000000000000000000000>:0)
Localization.LocalizationManagerUnity.SelectLocaleAsync (UnityEngine.Localization.Locale locale) (at <00000000000000000000000000000000>:0)```

Hi, This is an addressables error, it typically occurs when you try to force loading (WaitForCompletion) inside of an addressables callback. Such as trying to use a table when its not loaded yet. If you are getting these errors you can usually work around them by deferring your code that is inside of a callback to a later point, for example, when the callback occurs set some variables on a MonoBehaviour and then let it pick them up during its Update call. This idea is you dont want to do any additional loading whilst still inside of the callback.

If you want the tables to be loaded after the locale then the preload option is for this, its safer and avoids the above error. The system will first load the locale and then preload tables so it will be ready when you get the selected locale changed callback.

1 Like