Search Unity

Null Reference Exception when changing language

Discussion in 'Localization Tools' started by microteq, Jul 30, 2021.

  1. microteq

    microteq

    Joined:
    Jun 17, 2021
    Posts:
    7
    Hi

    With the localization package 1.0.0-pre.10 (and also pre.9) we get a null reference exception when changing the language in our script by using:

    LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.Locales[index];

    index can be 0 or 1, because we use two languages.

    The exception is:

    NullReferenceException: Object reference not set to an instance of an object
    UnityEngine.Localization.LocalizedTable`2[TTable,TEntry].AutomaticLoadingCompleted (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[TObject] loadOperation) (at Library/PackageCache/com.unity.localization@1.0.0-pre.10/Runtime/Localized Reference/LocalizedTable.cs:176)
    DelegateList`1[T].Invoke (T res) (at Library/PackageCache/com.unity.addressables@1.18.11/Runtime/ResourceManager/Util/DelegateList.cs:69)
    UnityEngine.Debug:LogException(Exception)
    DelegateList`1:Invoke(AsyncOperationHandle`1) (at Library/PackageCache/com.unity.addressables@1.18.11/Runtime/ResourceManager/Util/DelegateList.cs:73)
    UnityEngine.Localization.LoadTableOperation`2:TableLoaded(AsyncOperationHandle`1)
    DelegateList`1:Invoke(AsyncOperationHandle`1) (at Library/PackageCache/com.unity.addressables@1.18.11/Runtime/ResourceManager/Util/DelegateList.cs:69)
    UnityEngine.ResourceManagement.Util.DelayedActionManager:LateUpdate() (at Library/PackageCache/com.unity.addressables@1.18.11/Runtime/ResourceManager/Util/DelayedActionManager.cs:159)

    the variable that is null in the script LocalizedTable.cs is m_ChangeHandler.

    Many thanks
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,282