Search Unity

Error on OnLocaleChanged

Discussion in 'Localization Tools' started by Phanou, May 2, 2021.

  1. Phanou

    Phanou

    Joined:
    Jan 4, 2017
    Posts:
    11
    Hi

    I discover this amazing package but I have some trouble to use it.
    I imported package v0.11.1
    I Configured Localization settings with 'fr' and 'en' language.
    upload_2021-5-2_23-37-53.png
    I added a UI_TEST table with a key 'LANGUAGE'
    upload_2021-5-2_23-38-57.png

    added a component 'Localize string event'
    upload_2021-5-2_23-41-0.png

    I always have this error message

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. UnityEngine.Localization.Settings.LocalizedDatabase`2[TTable,TEntry].OnLocaleChanged (UnityEngine.Localization.Locale locale) (at Library/PackageCache/com.unity.localization@0.11.1-preview/Runtime/Settings/Database/LocalizedDatabase.cs:418)
    3. UnityEngine.Localization.Settings.LocalizedDatabase`2[TTable,TEntry].ResetState () (at Library/PackageCache/com.unity.localization@0.11.1-preview/Runtime/Settings/Database/LocalizedDatabase.cs:445)
    4. UnityEngine.Localization.Settings.LocalizationSettings.ResetState () (at Library/PackageCache/com.unity.localization@0.11.1-preview/Runtime/Settings/LocalizationSettings.cs:491)
    5. UnityEngine.Localization.Settings.LocalizationSettings.OnDisable () (at Library/PackageCache/com.unity.localization@0.11.1-preview/Runtime/Settings/LocalizationSettings.cs:180)
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    Hi,
    This looks like a bug. I had a go at reproducing it but could not.
    What version of Unity are you using?
    It looks familiar to an old bug with SerializeReference. This was fixed some time ago though. It may be worth updating to the latest patch release of the version you are using.
     
    manshulb likes this.
  3. Phanou

    Phanou

    Joined:
    Jan 4, 2017
    Posts:
    11
    Hi @karl_jones

    I'm using Unity v2020.1.6f1.
    I use all this package in my VR project :
    upload_2021-5-3_13-56-57.png

    Another problem, I don't see at runtime the dropdown language list
    upload_2021-5-3_13-54-17.png
     
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    Do you mean in the player you don't see it? It's an editor only feature. We include some Samples to show how to do it in the player. You can get to them via the package manager window.
     
  5. Phanou

    Phanou

    Joined:
    Jan 4, 2017
    Posts:
    11
    I never saw it, in Editor or in Player.
     
  6. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    It's probably related to the original problem you are having. Please file a bug report so I can take a look at your project and understand what has gone wrong.
     
  7. Phanou

    Phanou

    Joined:
    Jan 4, 2017
    Posts:
    11
    Ok I will create a bug report.
    Last detail, I don't know if there is a relation between "Localization" package and "XR Interaction Toolkit" package but as soon as I add Localization, XRRig component doesn't work at all.
     
    karl_jones likes this.
  8. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    There's no connection between those 2 packages so that's strange, sounds like a bug.
     
  9. Canazza

    Canazza

    Joined:
    Feb 10, 2011
    Posts:
    14
    Hi, I'm having the same problem on Unity 2020.1.3f1

    I've tracked it down to LocalizedDatabase.cs line 418

    In the foreach loop in OnLocaleChanged, TableOperations is null.
    upload_2021-5-4_12-39-7.png

    This shouldn't be possible, since TableOperations is automatically assigned and is read-only.

    upload_2021-5-4_12-38-0.png

    This is a brand new, empty project. I've set up one local (en-gb), one Asset Table and one String Table.

    [edit] I've also attached the project to a bug report, and to this reply
     

    Attached Files:

    • Test.zip
      File size:
      54.6 KB
      Views:
      274
    Last edited: May 4, 2021
  10. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    Can you try updating to 2020.3? This is an old bug with serializereference that should be fixed In the latest version.
     
    manshulb likes this.
  11. Canazza

    Canazza

    Joined:
    Feb 10, 2011
    Posts:
    14
    Yeah that looks like it's working in 2020.3.6f1

    Case 1333659 can be closed I guess
     
    manshulb and karl_jones like this.
  12. manshulb

    manshulb

    Joined:
    Oct 18, 2018
    Posts:
    1
    Yes, updating unity version to 2020.3 worked for me as well.
     
    karl_jones likes this.
  13. alexandra291

    alexandra291

    Joined:
    Feb 7, 2020
    Posts:
    5
    I have the same issue on version 2019.4.3f1. I created new project just to test this package and it worked! And as soon as I changed version to 2019.4.3f it stopped working and same error appeared. The version of Unity I initially tested it on was 2019.4.20f1 - on this version it is working. Unfortunally I cant downgrade my main project to that version, it couses lots of errors.