From 9700a6ad3dbf3275ebaec8ba10f174d7b9bf32fe Mon Sep 17 00:00:00 2001 From: Hertzole Date: Tue, 16 Jan 2024 22:56:24 +0100 Subject: [PATCH] Revert "fix: OnValueChanged not being invoked when calling ResetValue" This reverts commit 0835d1a0a7830899b557ac32d60df73624c9fbe6. --- CHANGELOG.md | 1 - .../Runtime/Values/ScriptableValue.cs | 15 --------------- .../Tests/Editor/ResetValuesTests_Values.cs | 18 ------------------ 3 files changed, 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 415e0e2..12e405f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,6 @@ - Fixed scriptable value editor breaking if the value is null - Fixed scriptable value editor having the wrong height in newer Unity versions -- Fixed OnValueChanged not being invoked when resetting the value on a scriptable value - Fixed the package not having an author ## [1.2.0] - 2023-05-20 diff --git a/Packages/se.hertzole.scriptable-values/Runtime/Values/ScriptableValue.cs b/Packages/se.hertzole.scriptable-values/Runtime/Values/ScriptableValue.cs index 27002ef..a2b8813 100644 --- a/Packages/se.hertzole.scriptable-values/Runtime/Values/ScriptableValue.cs +++ b/Packages/se.hertzole.scriptable-values/Runtime/Values/ScriptableValue.cs @@ -197,25 +197,10 @@ protected override void OnStart() /// public void ResetValue() { - T previousValue = value; - bool isSameValue = EqualityHelper.Equals(value, DefaultValue); - - if (!isSameValue) - { - onValueChanging.Invoke(previousValue, DefaultValue); - OnValueChanging?.Invoke(previousValue, DefaultValue); - } - value = DefaultValue; PreviousValue = DefaultValue; temporaryValue = DefaultValue; valueIsDefault = EqualityHelper.Equals(value, default); - - if (!isSameValue) - { - onValueChanged.Invoke(previousValue, DefaultValue); - OnValueChanged?.Invoke(previousValue, DefaultValue); - } } /// diff --git a/Packages/se.hertzole.scriptable-values/Tests/Editor/ResetValuesTests_Values.cs b/Packages/se.hertzole.scriptable-values/Tests/Editor/ResetValuesTests_Values.cs index e0d2027..241e417 100644 --- a/Packages/se.hertzole.scriptable-values/Tests/Editor/ResetValuesTests_Values.cs +++ b/Packages/se.hertzole.scriptable-values/Tests/Editor/ResetValuesTests_Values.cs @@ -85,9 +85,6 @@ public void ScriptableString_ResetValue() private void ScriptableValueReset(TValue initialValue, TValue newValue) where TType : ScriptableValue { - bool changingInvoked = false; - bool changedInvoked = false; - TType instance = CreateInstance(); instance.Value = initialValue; @@ -98,23 +95,8 @@ private void ScriptableValueReset(TValue initialValue, TValue new instance.Value = newValue; Assert.AreEqual(newValue, instance.Value); - - instance.OnValueChanging += (_, newChangedValue) => - { - changingInvoked = true; - Assert.AreEqual(initialValue, newChangedValue); - }; - - instance.OnValueChanged += (_, newChangedValue) => - { - changedInvoked = true; - Assert.AreEqual(initialValue, newChangedValue); - }; instance.Test_OnStart(); - - Assert.IsTrue(changingInvoked); - Assert.IsTrue(changedInvoked); Assert.AreEqual(initialValue, instance.Value); }