Search Unity

Resolved Do we have to preload LocalizationSettings on every scene?

Discussion in 'Localization Tools' started by Goty-Metal, Jan 3, 2021.

  1. Goty-Metal

    Goty-Metal

    Joined:
    Apr 4, 2020
    Posts:
    168
    Hi there, i'm having an issue with LocalizedStrings not being ready (x.IsDone = false) at the start of the scene.
    I do preload them (yield return LocalizationSettings.InitializationOperation;) on the first scene of my game (menu) but if i load another scene i get "isDone = false" again (basically empty strings if i try to get the result of the LocalizedString... so, do i have to preload the LocalizationSettings on EVERY scene?

    Thanks! =D
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,299
    No, you should not need to do it every scene. We made some improvements to our Addressables integration that may fix this in 0.10.0. If the problem still persists then please file a bug report. We hope to release 0.10.0 by the end of Jan.
     
    Goty-Metal likes this.
  3. Goty-Metal

    Goty-Metal

    Joined:
    Apr 4, 2020
    Posts:
    168
    Thanks for the fast reply! looking forward the new update :)
     
    karl_jones likes this.
  4. Goty-Metal

    Goty-Metal

    Joined:
    Apr 4, 2020
    Posts:
    168
    Hi again, i had to bump this because i'm already working with 0.10.0 but still having preloading issues... i'm making sure that "LocalizationSettings.InitializationOperation" is done (yield return LocalizationSettings.InitializationOperation within a corutine) before accessing any LocalizedString on EVERY scene, however, i ALSO to call "myLocalizedString.GetLocalizedString().IsDone" on every single LocalizedString (again within a corutine to wait until is done) otherwise i get empty strings on the result...
    I don't know if i'm just doing it wrong somehow... is there any way to make sure all LocalizedStrings will be ready to use ONCE and FOR ALL (at least in the same scene so i don't have to preload every single LocalizedString i'm going to use on every scene).


    Thanks in advance!
     
  5. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,299
    Are all your tables marked as preload?
     
    Goty-Metal likes this.
  6. Goty-Metal

    Goty-Metal

    Joined:
    Apr 4, 2020
    Posts:
    168
    Oops, you're right, i had this issue in another project which already had all tables set to preload but forgot to mark the ones on this project, now is working perfectly.
    So THANKS and APOLOGIES.

    Just to help anyone that falls here:
    You CAN preload ALL the tables you need in the start of your game, let's say splash screen, preload screen, whathever... and any scene you transition to after that will have the localized strings ready to go aswell, just don't forget to MARK your TABLES to preload (Preload Table on the "Edit Metadata Tab" or "Preload All Tables" if you don't want to pick every single lang from the table) and wait for "LocalizationSettings.InitializationOperation" in your preload corutine:
    Code (CSharp):
    1.     IEnumerator Start() {
    2.         // Wait for Localization to load
    3.         yield return LocalizationSettings.InitializationOperation;
    4.  
    5.         // Load previous data from file if any or create defaults...
    6.  
    7.         // Rest of preloading stuff...
    8.     }
     
    karl_jones likes this.
  7. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,299
    Do you think it would be better to just have a single preload option for all tables instead of setting it per table?
     
    Goty-Metal likes this.
  8. Goty-Metal

    Goty-Metal

    Joined:
    Apr 4, 2020
    Posts:
    168
    Is good to have the option to pick just some tables, it really depends on the project, but in my case for all my projects is better to preload all tables, so an option (in localization_settings maybe?) would be great in my case... "Preload All Tables" checkbox sounds good.

    By the way after some testings on 2 different projects everything runs smooth now, tables preload pretty fast and the localized strings are available in every scene instantly after that 10/10.
     
    karl_jones likes this.
  9. chehob

    chehob

    Joined:
    Oct 25, 2017
    Posts:
    8
    Where can I find these options to preload tables? I dont have it on my Localization window
    111.jpg
     
    Goty-Metal likes this.
  10. Goty-Metal

    Goty-Metal

    Joined:
    Apr 4, 2020
    Posts:
    168
    The button with a page and a blue icon, the ones over "English (en)" and "Russian (ru)" any of them will work;)
     
    karl_jones and chehob like this.
  11. chehob

    chehob

    Joined:
    Oct 25, 2017
    Posts:
    8
    wow, ok, thank you. I was losing my mind trying to find it :D
     
    Goty-Metal likes this.
  12. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,299
    A UX review is on our list later in the year :)
     
    chehob likes this.
  13. chehob

    chehob

    Joined:
    Oct 25, 2017
    Posts:
    8
    well it was really my bad, this is explained in the docs, but I cant read properly I guess :confused:
     
    karl_jones likes this.