So I have my localization working just fine in the editor. Just a few string tables and one sprite table.
Tried a build and run and sure get this error in Chrome
build.framework.js:3 Exception: WebGLPlayer does not support synchronous Addressable loading. Please do not use WaitForCompletion on the WebGLPlayer platform.
at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].WaitForCompletion () [0x00000] in <00000000000000000000000000000000>:0
After half an hour of googling I still have no idea what to do differently to get aroundt this. Any help?
As the error says, you can not use WaitForCompletion in WebGL, this is a limitation of Addressables. If you are calling any synchronous methods (SelectedLocale, GetLocalizedString etc) then they will use WaitForCompletion internally if the data has not already been loaded. You need to let the localization system initialize before you use it by waiting on LocalizationSettings.InitializationOperation.
in Start2 it opens a websocket and gets game data including chat history. The chat history has some random bot chatter that is contained in a string table.
string key = "botchat" + UnityEngine.Random.Range(1, 29);
var op = LocalizationSettings.StringDatabase.GetLocalizedString("bot-chat", key);
This fails on first load with the above error even though it is now clearly behind the InitializationOperation. Just have in a try catch now so it doesn’t crash entirely.
When I end turn after a few seconds and get new chat messages it works.
If your string table is not marked as preload then it will be loaded on demand when its first used. This is likely what’s happening here. Try marking the table as preload. String Tables | Localization | 1.4.5