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 have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

String Localization doesn't turn green. AssertionException: Assertion failure. Value was Null

Discussion in 'Localization Tools' started by Glitshy, Sep 22, 2021.

  1. Glitshy

    Glitshy

    Joined:
    May 26, 2018
    Posts:
    15
    Hello,

    I've got the Localization package to work with some TMP Texts already, where usually once I add the lcoalization component and select my string reference, the text turns green and is then controlled by the selected Reference.
    However, when I select one of the strings I recently added to the table which I didn''t get working already, It doesn't turn green and I get the following error every time the string attempts to update (I change language):

    AssertionException: Assertion failure. Value was Null
    Expected: Value was not Null
    UnityEngine.Assertions.Assert.Fail (System.String message, System.String userMessage) (at <4dc2257427d341fb9842705f290f2b68>:0)
    UnityEngine.Assertions.Assert.IsNotNull (UnityEngine.Object value, System.String message) (at <4dc2257427d341fb9842705f290f2b68>:0)
    UnityEngine.Assertions.Assert.IsNotNull[T] (T value, System.String message) (at <4dc2257427d341fb9842705f290f2b68>:0)
    UnityEngine.Assertions.Assert.IsNotNull[T] (T value) (at <4dc2257427d341fb9842705f290f2b68>:0)
    UnityEngine.Localization.Tables.TableEntry.get_SharedEntry () (at Library/PackageCache/com.unity.localization@1.0.0-pre.9/Runtime/Tables/DetailedLocalizationTable.cs:35)
    UnityEngine.Localization.GetTableEntryOperation`2[TTable,TEntry].HandleEntryOverride (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[TObject] asyncOperation, TEntry entry) (at Library/PackageCache/com.unity.localization@1.0.0-pre.9/Runtime/Operations/GetTableEntryOperation.cs:84)
    UnityEngine.Localization.GetTableEntryOperation`2[TTable,TEntry].ExtractEntryFromTable (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[TObject] asyncOperation) (at Library/PackageCache/com.unity.localization@1.0.0-pre.9/Runtime/Operations/GetTableEntryOperation.cs:61)
    UnityEngine.Localization.GetTableEntryOperation`2[TTable,TEntry].Execute () (at Library/PackageCache/com.unity.localization@1.0.0-pre.9/Runtime/Operations/GetTableEntryOperation.cs:47)
    UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].InvokeExecute () (at Library/PackageCache/com.unity.addressables@1.18.15/Runtime/ResourceManager/AsyncOperations/AsyncOperationBase.cs:474)
    UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].Start (UnityEngine.ResourceManagement.ResourceManager rm, UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle dependency, DelegateList`1[T] updateCallbacks) (at Library/PackageCache/com.unity.addressables@1.18.15/Runtime/ResourceManager/AsyncOperations/AsyncOperationBase.cs:469)
    UnityEngine.ResourceManagement.ResourceManager.StartOperation[TObject] (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject] operation, UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle dependency) (at Library/PackageCache/com.unity.addressables@1.18.15/Runtime/ResourceManager/ResourceManager.cs:458)
    UnityEngine.Localization.Settings.LocalizedDatabase`2[TTable,TEntry].GetTableEntryAsync (UnityEngine.Localization.Tables.TableReference tableReference, UnityEngine.Localization.Tables.TableEntryReference tableEntryReference, UnityEngine.Localization.Locale locale, UnityEngine.Localization.Settings.FallbackBehavior fallbackBehavior) (at Library/PackageCache/com.unity.localization@1.0.0-pre.9/Runtime/Settings/Database/LocalizedDatabase.cs:448)
    UnityEngine.Localization.LocalizedString.HandleLocaleChange (UnityEngine.Localization.Locale _) (at Library/PackageCache/com.unity.localization@1.0.0-pre.9/Runtime/Localized Reference/LocalizedString.cs:340)
    UnityEngine.Localization.LocalizedString.ForceUpdate () (at Library/PackageCache/com.unity.localization@1.0.0-pre.9/Runtime/Localized Reference/LocalizedString.cs:264)
    UnityEngine.Localization.LocalizedString.add_StringChanged (UnityEngine.Localization.LocalizedString+ChangeHandler value) (at Library/PackageCache/com.unity.localization@1.0.0-pre.9/Runtime/Localized Reference/LocalizedString.cs:94)
    UnityEngine.Localization.Components.LocalizeStringEvent.RegisterChangeHandler () (at Library/PackageCache/com.unity.localization@1.0.0-pre.9/Runtime/Component Localizers/LocalizeStringEvent.cs:123)
    UnityEngine.Localization.Components.LocalizeStringEvent.OnEnable () (at Library/PackageCache/com.unity.localization@1.0.0-pre.9/Runtime/Component Localizers/LocalizeStringEvent.cs:81)

    It looks like this:

    upload_2021-9-22_20-26-27.png

    When I try to change the string reference in my prefab from one which worked to one which doesn't works, it stays green but the string doens't update. I get the following error:
    AssertionException: Assertion failure. Value was Null
    Expected: Value was not Null
    UnityEngine.Assertions.Assert.Fail (System.String message, System.String userMessage) (at <4dc2257427d341fb9842705f290f2b68>:0)
    UnityEngine.Assertions.Assert.IsNotNull (UnityEngine.Object value, System.String message) (at <4dc2257427d341fb9842705f290f2b68>:0)
    UnityEngine.Assertions.Assert.IsNotNull[T] (T value, System.String message) (at <4dc2257427d341fb9842705f290f2b68>:0)
    UnityEngine.Assertions.Assert.IsNotNull[T] (T value) (at <4dc2257427d341fb9842705f290f2b68>:0)
    UnityEngine.Localization.Tables.TableEntry.get_SharedEntry () (at Library/PackageCache/com.unity.localization@1.0.0-pre.9/Runtime/Tables/DetailedLocalizationTable.cs:35)
    UnityEngine.Localization.GetTableEntryOperation`2[TTable,TEntry].HandleEntryOverride (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[TObject] asyncOperation, TEntry entry) (at Library/PackageCache/com.unity.localization@1.0.0-pre.9/Runtime/Operations/GetTableEntryOperation.cs:84)
    UnityEngine.Localization.GetTableEntryOperation`2[TTable,TEntry].ExtractEntryFromTable (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[TObject] asyncOperation) (at Library/PackageCache/com.unity.localization@1.0.0-pre.9/Runtime/Operations/GetTableEntryOperation.cs:61)
    UnityEngine.Localization.GetTableEntryOperation`2[TTable,TEntry].Execute () (at Library/PackageCache/com.unity.localization@1.0.0-pre.9/Runtime/Operations/GetTableEntryOperation.cs:47)
    UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].InvokeExecute () (at Library/PackageCache/com.unity.addressables@1.18.15/Runtime/ResourceManager/AsyncOperations/AsyncOperationBase.cs:474)
    UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].Start (UnityEngine.ResourceManagement.ResourceManager rm, UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle dependency, DelegateList`1[T] updateCallbacks) (at Library/PackageCache/com.unity.addressables@1.18.15/Runtime/ResourceManager/AsyncOperations/AsyncOperationBase.cs:469)
    UnityEngine.ResourceManagement.ResourceManager.StartOperation[TObject] (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject] operation, UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle dependency) (at Library/PackageCache/com.unity.addressables@1.18.15/Runtime/ResourceManager/ResourceManager.cs:458)
    UnityEngine.Localization.Settings.LocalizedDatabase`2[TTable,TEntry].GetTableEntryAsync (UnityEngine.Localization.Tables.TableReference tableReference, UnityEngine.Localization.Tables.TableEntryReference tableEntryReference, UnityEngine.Localization.Locale locale, UnityEngine.Localization.Settings.FallbackBehavior fallbackBehavior) (at Library/PackageCache/com.unity.localization@1.0.0-pre.9/Runtime/Settings/Database/LocalizedDatabase.cs:448)
    UnityEngine.Localization.LocalizedString.HandleLocaleChange (UnityEngine.Localization.Locale _) (at Library/PackageCache/com.unity.localization@1.0.0-pre.9/Runtime/Localized Reference/LocalizedString.cs:340)
    UnityEngine.Localization.LocalizedString.ForceUpdate () (at Library/PackageCache/com.unity.localization@1.0.0-pre.9/Runtime/Localized Reference/LocalizedString.cs:264)
    UnityEngine.Localization.LocalizedReference.ChangedThroughSerialization () (at Library/PackageCache/com.unity.localization@1.0.0-pre.9/Runtime/Localized Reference/LocalizedReference.cs:156)
    UnityEditor.EditorApplication.Internal_CallDelayFunctions () (at <8a8bf68eb0e443b196386a376561c6a1>:0)

    I am actually unsure how I got some strings from my Table to work in the first place :confused:

    Any help appreciated and thanks in advance!
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,876
    That error indicates that the string tables shared table data is null. Did you delete it?
    Can you try localization 1.0.1?
     
  3. Glitshy

    Glitshy

    Joined:
    May 26, 2018
    Posts:
    15
    I definitely didn't delete it. After restarting the Editor the references which I selected but didn't previously work do work now.
    I did upgrade from 1.0.0 to 1.0.1 just now (didn't see how to update until I looked it up after you pointed out there's a new version). When I add a new entry to my string table it seems to immediately work now!

    However, when I load and play my scene with my Language select dropdown I get these 4 errors:

    UnityEngine.AddressableAssets.InvalidKeyException: Exception of type 'UnityEngine.AddressableAssets.InvalidKeyException' was thrown., Key=0e3d1140fe544b542a0e5dc8f88651d6, Type=UnityEngine.Localization.Tables.SharedTableData
    UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1/<>c__DisplayClass57_0<UnityEngine.AddressableAssets.ResourceLocators.IResourceLocator>:<add_CompletedTypeless>b__0 (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.AddressableAssets.ResourceLocators.IResourceLocator>)
    DelegateList`1<UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.AddressableAssets.ResourceLocators.IResourceLocator>>:Invoke (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.AddressableAssets.ResourceLocators.IResourceLocator>) (at Library/PackageCache/com.unity.addressables@1.19.4/Runtime/ResourceManager/Util/DelegateList.cs:69)
    UnityEngine.AddressableAssets.Initialization.InitializationOperation/<>c__DisplayClass18_0:<LoadContentCatalogInternal>b__0 (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.AddressableAssets.ResourceLocators.IResourceLocator>)
    DelegateList`1<UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.AddressableAssets.ResourceLocators.IResourceLocator>>:Invoke (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.AddressableAssets.ResourceLocators.IResourceLocator>) (at Library/PackageCache/com.unity.addressables@1.19.4/Runtime/ResourceManager/Util/DelegateList.cs:69)
    UnityEngine.ResourceManagement.ChainOperation`2<UnityEngine.AddressableAssets.ResourceLocators.IResourceLocator, UnityEngine.AddressableAssets.ResourceLocators.ContentCatalogData>:OnWrappedCompleted (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.AddressableAssets.ResourceLocators.IResourceLocator>)
    DelegateList`1<UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.AddressableAssets.ResourceLocators.IResourceLocator>>:Invoke (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.AddressableAssets.ResourceLocators.IResourceLocator>) (at Library/PackageCache/com.unity.addressables@1.19.4/Runtime/ResourceManager/Util/DelegateList.cs:69)
    UnityEngine.Localization.Components.LocalizeStringEvent:OnEnable ()
    OptionsMenu:ButtonOptionsGeneral () (at Assets/Scripts/UI/OptionsMenu.cs:18)
    UnityEngine.EventSystems.ExecuteEvents:Execute<UnityEngi


    OperationException : ChainOperation failed because dependent operation failed
    UnityEngine.AddressableAssets.InvalidKeyException: Exception of type 'UnityEngine.AddressableAssets.InvalidKeyException' was thrown., Key=0e3d1140fe544b542a0e5dc8f88651d6, Type=UnityEngine.Localization.Tables.SharedTableData
    UnityEngine.ResourceManagement.ChainOperationTypelessDepedency`1<UnityEngine.Localization.Tables.SharedTableData>:OnWrappedCompleted (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.Localization.Tables.SharedTableData>)
    DelegateList`1<UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.Localization.Tables.SharedTableData>>:Invoke (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.Localization.Tables.SharedTableData>) (at Library/PackageCache/com.unity.addressables@1.19.4/Runtime/ResourceManager/Util/DelegateList.cs:69)
    UnityEngine.Localization.Components.LocalizeStringEvent:OnEnable ()
    OptionsMenu:ButtonOptionsGeneral () (at Assets/Scripts/UI/OptionsMenu.cs:18)
    UnityEngine.EventSystems.EventSystem:Update () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:501)

    OperationException : Failed to extract table name from shared table data TableReference(0e3d1140-fe54-4b54-2a0e-5dc8f88651d6 - ). Load Shared Table data operation failed.

    UnityEngine.Localization.LoadTableOperation`2<UnityEngine.Localization.Tables.StringTable, UnityEngine.Localization.Tables.StringTableEntry>:LoadTableByGuid (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.Localization.Tables.SharedTableData>)
    DelegateList`1<UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.Localization.Tables.SharedTableData>>:Invoke (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.Localization.Tables.SharedTableData>) (at Library/PackageCache/com.unity.addressables@1.19.4/Runtime/ResourceManager/Util/DelegateList.cs:69)
    UnityEngine.Localization.Components.LocalizeStringEvent:OnEnable ()
    OptionsMenu:ButtonOptionsGeneral () (at Assets/Scripts/UI/OptionsMenu.cs:18)
    UnityEngine.EventSystems.EventSystem:Update () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:501)

    OperationException : Load Table Operation Failed

    UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1/<>c__DisplayClass57_0<UnityEngine.Localization.Tables.StringTable>:<add_CompletedTypeless>b__0 (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.Localization.Tables.StringTable>)
    DelegateList`1<UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.Localization.Tables.StringTable>>:Invoke (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.Localization.Tables.StringTable>) (at Library/PackageCache/com.unity.addressables@1.19.4/Runtime/ResourceManager/Util/DelegateList.cs:69)
    UnityEngine.Localization.Components.LocalizeStringEvent:OnEnable ()
    OptionsMenu:ButtonOptionsGeneral () (at Assets/Scripts/UI/OptionsMenu.cs:18)
    UnityEngine.EventSystems.EventSystem:Update () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:501)

    The code for my Langauge Selection is from the guide https://docs.unity3d.com/Packages/com.unity.localization@0.3/manual/index.html Tutorial 4.
     
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,876
  5. Glitshy

    Glitshy

    Joined:
    May 26, 2018
    Posts:
    15
    It was the top result on Google when searching for "unity localization", good to know there's something newer.
    The example in the old link still worked with 1.0.0 for switching langauges with a dropdown, with the exception that I had to add
    using UnityEngine.Localization.Settings;


    Anyways, I ran the Addressables Analyzer and it seemed to have fixed my problem....
    But now my whole Editor occasionaly freezes when switching languages, both with my code or with the Localization Scene Controls. It seems to work when I start the editor, hit play and then can change the locale back and forth as much as I want, but when I stop Playing hit play again, it always freezes on the first switch. Complete freeze, I have to close it with task manager.

    Also, is it supposed to always set the Langauge to "None" on Editor start?
    I thought according to this it should always start with English https://docs.unity3d.com/Packages/c...uideWithVariants.html#choose-a-default-locale

    My settings:
    upload_2021-9-23_22-12-8.png

    Any help appreciated and thanks for the help so far!
     
  6. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,876
    When out of play mode the language will be None. We have the play mode language which is picked using the Locale Selectors and then out of play mode the editor language which will be None(default) or the one that it was before you entered playmode. The idea being you can switch between languages in edit mode to preview them but then switch back to None when making general changes in the Editor so that you dont have the overhead. More info on the settings are here https://docs.unity3d.com/Packages/com.unity.localization@1.0/manual/LocalizedPropertyVariants.html



    If you are able to reproduce the locking editor then please file a bug report so we can look into it.
     
  7. Glitshy

    Glitshy

    Joined:
    May 26, 2018
    Posts:
    15
    Ok, so is it supposed to switch when hitting play? Cause it stays at none. Or am I supposed to use something like
    LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.Locales[index];


    Because when I use that code, it doesn't switch back to none after I stop playing.


    It does happen relyable how I've described, I'll have to check if it happens also when I start a new project I guess.
     
  8. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,876
    Hmm it should switch when entering playmode. If you do manage to reproduce it then please file a bug report.