Skip to content

Commit

Permalink
Revert "fix: OnValueChanged not being invoked when calling ResetValue"
Browse files Browse the repository at this point in the history
This reverts commit 0835d1a.
  • Loading branch information
Hertzole committed Jan 16, 2024
1 parent 5625fc4 commit 9700a6a
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 34 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,25 +197,10 @@ protected override void OnStart()
/// </summary>
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);
}
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ public void ScriptableString_ResetValue()

private void ScriptableValueReset<TType, TValue>(TValue initialValue, TValue newValue) where TType : ScriptableValue<TValue>
{
bool changingInvoked = false;
bool changedInvoked = false;

TType instance = CreateInstance<TType>();

instance.Value = initialValue;
Expand All @@ -98,23 +95,8 @@ private void ScriptableValueReset<TType, TValue>(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);
}
Expand Down

0 comments on commit 9700a6a

Please sign in to comment.