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.
  2. We are updating our Terms of Service for all Unity subscription plans, effective October 13, 2022, to create a more streamlined, user-friendly set of terms. Please review them here: unity.com/legal/terms-of-service.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice
  4. Join us on Thursday, September 29, for a day with Unity's SRP teams here on the forum or on Reddit, and discuss topics around URP, HDRP, and the Scriptable Render Pipeline in general.
    Dismiss Notice

"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:
    187
    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:
    6,663
    Try calling LocalizationSettings.InitialozationOperation.WaitForCompletion()
    Before you do anything with localization.
     
  3. CrowbarSka

    CrowbarSka

    Joined:
    Dec 15, 2009
    Posts:
    187
    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:
    6,663
    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:
    187
    Ahh OK. Thanks for the info!
     
    karl_jones likes this.
unityunity