I have a simple project on unity 2021.2.11 on platform Webgl
Localization 1.0.5
Adressable 1.20.0
I created 2 Locale (fr, en)
I create an AssetTable just contain a texture (one for each locale)
Textures are in Adressables
I built adressable
I try to GetTableAsync using this coroutine:
public IEnumerator GetMyTable(LocalizedAssetTable d)
{
yield return LocalizationSettings.InitializationOperation;
var tableOp = d.GetTableAsync();
yield return tableOp;
AssetTable table = tableOp.Result;
if (table == null)
{
result = "Table NULL";
Debug.Log("<color=red>"+ result+"</color>");
}
else
{
result = "Table OK";
Debug.Log("<color=green>" + result + "</color>");
var tableOp2 = LocalizationSettings.AssetDatabase.GetLocalizedAssetAsync<Texture2D>(d.TableReference, "T");
yield return tableOp2;
tex = tableOp2.Result;
}
}
Runing in editor with Adressable PlayMode : Use Asset Database → Ok table is not null
Runing in build webgl —> Table is Null
Runing in editor with Adressable PlayMode : Use Existing Build → Table is Null
I can avoid this NULL problem if i uncheck Preload on table, but on webgl build there are many errors in console (even if afterwards it seems to work because i can display texture)
By executing SelectedLocale commands several times on all locale, the GetTableAsync function ends up no longer returning null … so strange
Why GetAsyncTable return null in this cases ?
What way to use on webgl ?
[EDIT]
I saw that package manager on unity 2021.2.11 allow to install 1.0.5 localization version… (why not the last ?)
Then after add manualy the latest version (1.3.2) using “Add package from git url” with com.unity.localization, the problem disapear in editor.
In build webgl, it works too, but there is many errors in console at start : Exception: WebGLPlayer does not support synchronous Addressable loading. Please do not use WaitForCompletion on the WebGLPlayer platform.
My scene is only a basic scene (camera + light) with one object with my script on.
And this script does nothing at start, only when press GUI button.
Then errors fire in web console at start then without execution of my code.
WaitForCompletion is being used from a script somewhere. See if you can find where it’s coming from. Don’t use any of the synchronous API. I can’t see any in the code you posted earlier. Can you share the full code?
Yes you are right i used LocalizationSettings.SelectedLocale in OnGUI to display current locale and i suppose i must use SelectedLocaleAsync instead…
Thanks for your reply !
Other question:
Is it normal that the unity 2021.2.11 package manager only offers version 1.0.5 of the localization package? instead of the last version 1.3.2 ?
Ok, unfortunaly this version has the bug mentioned in my first message.
I installed mannually the 1.3.2 package… seems no error but i’m afraid … can i do that without problem ?
I prefer not to change version of unity at this stage of the project…