Hi All,
I have been seeing this error for sometime but as it never caused any problems I ignored it until it started crashing builds. When I attempt to set smart variable values via:
profileTextIDVariable.Value = id;
profileTextProgressVariable.Value = ProfileManager.Instance.GetProgress(id);
var newGamePlusCount = ProfileManager.Instance.GetNewGamePlusCount(id); //GENERATES ERROR
profileTextNewGamePlusCountVariable.Value = newGamePlusCount <= 0 ? "" : $"+{newGamePlusCount}";
profileTextLocalizer.ApplyLocaleVariant(LocalizationSettings.SelectedLocale); //GENERATES ERROR
I get the following error:
NullReferenceException: Object reference not set to an instance of an object
at UnityEngine.Localization.PropertyVariants.TrackedObjects.JsonSerializerTrackedObject.ApplyLocale (UnityEngine.Localization.Locale variantLocale, UnityEngine.Localization.Locale defaultLocale) [0x00147] in .\Library\PackageCache\com.unity.localization@1.5.2\Runtime\Property Variants\Tracked Objects\JsonSerializerTrackedObject.cs:169
at UnityEngine.Localization.PropertyVariants.GameObjectLocalizer.ApplyLocaleVariant (UnityEngine.Localization.Locale locale, UnityEngine.Localization.Locale fallback) [0x0007f] in .\Library\PackageCache\com.unity.localization@1.5.2\Runtime\Property Variants\GameObjectLocalizer.cs:197
at UnityEngine.Localization.PropertyVariants.GameObjectLocalizer.ApplyLocaleVariant (UnityEngine.Localization.Locale locale) [0x00000] in .\Library\PackageCache\com.unity.localization@1.5.2\Runtime\Property Variants\GameObjectLocalizer.cs:171
at UnityEngine.Localization.PropertyVariants.GameObjectLocalizer.RequestUpdate () [0x00042] in .\Library\PackageCache\com.unity.localization@1.5.2\Runtime\Property Variants\GameObjectLocalizer.cs:269
at UnityEngine.Localization.PropertyVariants.GameObjectLocalizer.<RegisterChanges>b__18_0 (System.String _) [0x00000] in .\Library\PackageCache\com.unity.localization@1.5.2\Runtime\Property Variants\GameObjectLocalizer.cs:224
at UnityEngine.Localization.LocalizedString.InvokeChangeHandler (System.String value) [0x00023] in .\Library\PackageCache\com.unity.localization@1.5.2\Runtime\Localized Reference\LocalizedString.cs:699
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
UnityEngine.Localization.LocalizedString:InvokeChangeHandler(String) (at .\Library\PackageCache\com.unity.localization@1.5.2\Runtime\Localized Reference\LocalizedString.cs:710)
UnityEngine.Localization.LocalizedString:RefreshString() (at .\Library\PackageCache\com.unity.localization@1.5.2\Runtime\Localized Reference\LocalizedString.cs:235)
UnityEngine.Localization.LocalizedString:OnVariableChanged(IVariable) (at .\Library\PackageCache\com.unity.localization@1.5.2\Runtime\Localized Reference\LocalizedString.cs:678)
UnityEngine.Localization.SmartFormat.PersistentVariables.Variable`1:SendValueChangedEvent() (at .\Library\PackageCache\com.unity.localization@1.5.2\Runtime\Smart Format\Extensions\Persistent Variables\PersistentVariables.cs:46)
UnityEngine.Localization.SmartFormat.PersistentVariables.Variable`1:set_Value(Int32) (at .\Library\PackageCache\com.unity.localization@1.5.2\Runtime\Smart Format\Extensions\Persistent Variables\PersistentVariables.cs:39)
I am also seeing some warnings which I assume is contributing to the problem:
Attempting to Apply Variant when the previous operation has not yet completed.
UnityEngine.StackTraceUtility:ExtractStackTrace () (at C:/build/output/unity/unity/Runtime/Export/Scripting/StackTrace.cs:37)
UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[])
UnityEngine.Logger:Log (UnityEngine.LogType,object,UnityEngine.Object)
UnityEngine.Debug:LogWarning (object,UnityEngine.Object)
UnityEngine.Localization.PropertyVariants.GameObjectLocalizer:ApplyLocaleVariant (UnityEngine.Localization.Locale,UnityEngine.Localization.Locale) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Property Variants/GameObjectLocalizer.cs:185)
UnityEngine.Localization.PropertyVariants.GameObjectLocalizer:ApplyLocaleVariant (UnityEngine.Localization.Locale) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Property Variants/GameObjectLocalizer.cs:171)
UnityEngine.Localization.PropertyVariants.GameObjectLocalizer:SelectedLocaleChanged (UnityEngine.Localization.Locale) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Property Variants/GameObjectLocalizer.cs:107)
UnityEngine.Localization.PropertyVariants.GameObjectLocalizer/<Start>d__10:MoveNext () (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Property Variants/GameObjectLocalizer.cs:96)
UnityEngine.SetupCoroutine:InvokeMoveNext (System.Collections.IEnumerator,intptr) (at C:/build/output/unity/unity/Runtime/Export/Scripting/Coroutines.cs:17)
I have attempted to change async loading/sync loading, preloading options etc. but none seem to make a difference, any ideas?
Unity Editor 2022.3.46
Localization 1.5.2
Thanks!
Colton