Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

"Locales PreloadOperation has not been initialized" in standalone build

Discussion in 'Localization Tools' started by CrowbarSka, Nov 22, 2021.

  1. CrowbarSka

    CrowbarSka

    Joined:
    Dec 15, 2009
    Posts:
    192
    Hello! I have a problem when running my game in a standalone build. It works in editor (Unity 2020.3.22f1).

    I have a small "boot" scene that instantiates all my game manager scripts and loads save data. Once save data has been loaded, it looks at the player's language preference and tries to set the language to the one they last picked.

    I set the language like this:

    Code (CSharp):
    1. LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.Locales[localeIndex];
    However, this spits out the following error:
    Locales PreloadOperation has not been initialized, can not return the available locales.

    If I try to change the language manually a moment or so after that game has booted up then it works.

    I've looked for solutions in other threads on this forum and here are some that I've tried:
    • Made sure I'm using up-to-date Localization package (1.0.5) and Addressables package (1.19.11).
    • Deleted AddressableAssetsData folder and rebuild it via Analyzer tool.
    • Rebuild all Addressables via "Clean Build" then "New Build".
    • Built to a folder with a short pathname (i.e. at drive root).
    Some things I'm not sure about:
    1. I build my game via a build script... Does that mean I have to incorporate Addressables into that process? Or do I only need to do that if some localization data has changed?
    2. "Initialize Synchronously" is set to TRUE in Project Settings > Localization. Does that not protect me against this case? I assumed it would. If not, how can I know that ensure that the preload operation has started and completed before I start changing locales? When does the preload operation get triggered?
    Thanks!
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,915
    Try calling LocalizationSettings.InitialozationOperation.WaitForCompletion()
    Before you do anything with localization.
     
  3. CrowbarSka

    CrowbarSka

    Joined:
    Dec 15, 2009
    Posts:
    192
    That fixed it! Thanks so much for the quick reply.

    Out of interest, should "Initialize Synchronously" not do the same thing? Is that setting being ignored?
     
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,915
    It will do the same thing but calling LocalizationSettings.AvailableLocales.Locales does not go through any of the initialization paths. Ill make a bug to look into it.
     
    ATate and CrowbarSka like this.
  5. CrowbarSka

    CrowbarSka

    Joined:
    Dec 15, 2009
    Posts:
    192
    Ahh OK. Thanks for the info!
     
    karl_jones likes this.