Hello,
I don’t have that much time to report a bug with a correct use case but I encounter a small annoyment with the nested LocalizedString system.
This contains a LocalizeStringEvent that should be updated each time _populationCount or _populationLevel change.
In my update function, I just do the following
_milestonePopulationCountLocalisedVariable.Value = nextMilestoneInfo._populationCount;
_milestonePopulationLevelLocalisedVariable.Value = nextMilestoneInfo._populationLevel;
those two variables are assigned in my Start function from a reference assigned in the editor “MilestoneText” in the image
[SerializeField] private LocalizeStringEvent _milestoneText;
private LocalizedString _nextMilestoneLocalizedString;
private IntVariable _milestonePopulationCountLocalisedVariable;
private IntVariable _milestonePopulationLevelLocalisedVariable;
private void Start()
{
_nextMilestoneLocalizedString = _milestoneText.StringReference["_nextMilestone"] as LocalizedString;
_milestonePopulationCountLocalisedVariable = _nextMilestoneLocalizedString["_populationCount"] as IntVariable;
_milestonePopulationLevelLocalisedVariable = _nextMilestoneLocalizedString["_populationLevel"] as IntVariable;
}
The main problem is that changing the IntVariable(s) values does not update the Text value.
First “workaround”, I forced the LocalizeStringEvent to refresh _milestoneText.RefreshString();.
But, it comes with a pretty awful drawback, each time I exited the “play mode” it crashes with two call stacks
Exception: Reentering the Update method is not allowed. This can happen when calling WaitForCompletion on an operation while inside of a callback.
UnityEngine.ResourceManagement.ResourceManager.Update (System.Single unscaledDeltaTime) (at Library/PackageCache/com.unity.addressables@1.19.4/Runtime/ResourceManager/ResourceManager.cs:1067)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[TObject].WaitForCompletion () (at Library/PackageCache/com.unity.addressables@1.19.4/Runtime/ResourceManager/AsyncOperations/AsyncOperationHandle.cs:194)
UnityEngine.Localization.LocalizedString.GetLocalizedString () (at Library/PackageCache/com.unity.localization@1.0.3/Runtime/Localized Reference/LocalizedString.cs:249)
Pandora.Managers.GameManager.SendMessageEvent (Pandora.Events.GameEvent gameEvent) (at Assets/Pandora/Scripts/Managers/GameManager.cs:914)
Pandora.Managers.EventManager.TriggerEvent[TYPE_EVENT] (TYPE_EVENT gameEvent) (at Assets/Pandora/Scripts/Managers/EventManager.cs:90)
Pandora.Managers.SaveManager.SaveFileContent (Pandora.SaveData saveData, System.String saveName) (at Assets/Pandora/Scripts/Managers/SaveManager.cs:241)
Pandora.Managers.LoadingManager.ApplicationOnLogMessageReceived (System.String condition, System.String stacktrace, UnityEngine.LogType type) (at Assets/Pandora/Scripts/Managers/LoadingManager.cs:59)
UnityEngine.Application.CallLogCallback (System.String logString, System.String stackTrace, UnityEngine.LogType type, System.Boolean invokedOnMainThread) (at <ca496b8c93454b2f9b9924292c19379f>:0)
UnityEngine.Debug:LogException(Exception)
DelegateList`1:Invoke(AsyncOperationHandle`1) (at Library/PackageCache/com.unity.addressables@1.19.4/Runtime/ResourceManager/Util/DelegateList.cs:73)
UnityEngine.Localization.Components.LocalizeStringEvent:RefreshString()
Pandora.Ui.IngameUiLayout:Update() (at Assets/Pandora/Scripts/Ui/IngameUiLayout.cs:368)
MissingReferenceException: The object of type 'LocalizationBehaviour' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.MonoBehaviour.StartCoroutine (System.Collections.IEnumerator routine) (at <ca496b8c93454b2f9b9924292c19379f>:0)
UnityEngine.Localization.LocalizationBehaviour.ReleaseNextFrame (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle handle) (at Library/PackageCache/com.unity.localization@1.0.3/Runtime/Utilities/LocalizationBehaviour.cs:29)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1+<>c__DisplayClass57_0[TObject].<add_CompletedTypeless>b__0 (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[TObject] s) (at Library/PackageCache/com.unity.addressables@1.19.4/Runtime/ResourceManager/AsyncOperations/AsyncOperationBase.cs:291)
DelegateList`1[T].Invoke (T res) (at Library/PackageCache/com.unity.addressables@1.19.4/Runtime/ResourceManager/Util/DelegateList.cs:69)
UnityEngine.Debug:LogException(Exception)
DelegateList`1:Invoke(AsyncOperationHandle`1) (at Library/PackageCache/com.unity.addressables@1.19.4/Runtime/ResourceManager/Util/DelegateList.cs:73)
UnityEngine.Localization.Components.LocalizeStringEvent:RefreshString()
Pandora.Ui.IngameUiLayout:Update() (at Assets/Pandora/Scripts/Ui/IngameUiLayout.cs:368)
So second workaround to avoid that and sorry it is ugly but it prevents the crash as my values are not changing that often.
if ((_milestonePopulationCountLocalisedVariable.Value != nextMilestoneInfo._populationCount) || (_milestonePopulationLevelLocalisedVariable.Value != nextMilestoneInfo._populationLevel))
{
_milestonePopulationCountLocalisedVariable.Value = nextMilestoneInfo._populationCount;
_milestonePopulationLevelLocalisedVariable.Value = nextMilestoneInfo._populationLevel;
_milestoneText.RefreshString();
}
Sorry for the length of this post … but am I right in my way of doing and analysing? Is it a bug and if so, will it be fixed soon?
