Local Variables are not loading when loading scene from another one

Hi there,

I have a project using Unity Localization. Everything were just fine until I’ve tried to load my scene from another scene by a button. Scene is being loaded correctly but there is no local variable is loaded.

Afterwards when I change Active Locale from “Localization Scene Controls” it’s coming back.

Thanks in advance.

I’ve also uploaded the project:

This is an initialization issue. The problem is you are setting the value of year in the Start method however the GameObjectLocalizer also initializes in the Start method, it just happens to execute before your class so when it reads the value it is still empty.
Simplest way to fix this is to change LocalizationController to use Awake instead of Start.
Alternatively, you can also change the order Start is called in ProjectSettings/Script Execution Order.

@karl_jones thank you so much.

I could swear that I’ve given a shot for Awake earlier. So I made a little bit investigation and trials.

As far as I can see If I have a text attached with “Localize String Event” the problem occurs still but when I change it to “Game Object Localizer” then there is no problem.

I just want to let you know or I’m making a mistake when I’m using Localize String Event and binding it to text.

It’s a similar issue. LocalizedStringEvent uses OnEnable which is called from Awake. Changing the script execution order to make sure your script runs before the default would be one way to fix it.

Thank you so much.

One last question… Can I use both Localize String Event and Game Object Localizer ?

  • To use Localize String Event only binding text changes purposes.
  • To use Game Object Localizer only binding object changes(such as font, color, margin, padding…etc) purposes.

Thanks in advance.

Yes that’s fine

Thank you very much.

Changing the script execution order, putting GameObjectLocalizer before my custom scripts are not enough to prevent the issue. On Start the strings are not yet localized, after that, they are. :think:

This is a different issue. It’s waiting for addressables to initialize and load the data, it doesn’t happen instantly.
You could try yielding on LocalizationSettings.InitializationOperation.
You can also enable the WaitForCompletion option on the LocalizedStrings, this should force it to complete synchronously.