From 8d5f9bd3c86f7493051032431be2eff4ac3675ec Mon Sep 17 00:00:00 2001 From: Syntriax Date: Fri, 2 Dec 2022 00:09:21 +0300 Subject: [PATCH] Improvement --- ToggleStateMember.cs | 7 +++---- ToggleStateMonoBehaviour.cs | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/ToggleStateMember.cs b/ToggleStateMember.cs index 7ad0410..c6424f2 100644 --- a/ToggleStateMember.cs +++ b/ToggleStateMember.cs @@ -14,12 +14,11 @@ namespace Syntriax.Modules.ToggleState get => _isToggled; set { - bool oldValue = _isToggled; + if (value == _isToggled) + return; _isToggled = value; - - if (oldValue != value) - OnToggleStateChanged?.Invoke(value); + OnToggleStateChanged?.Invoke(value); } } diff --git a/ToggleStateMonoBehaviour.cs b/ToggleStateMonoBehaviour.cs index ace073a..e60ccb8 100644 --- a/ToggleStateMonoBehaviour.cs +++ b/ToggleStateMonoBehaviour.cs @@ -11,12 +11,11 @@ namespace Syntriax.Modules.ToggleState get => _isToggled; set { - bool oldValue = _isToggled; + if (value == _isToggled) + return; _isToggled = value; - - if (oldValue != value) - OnToggleStateChanged?.Invoke(value); + OnToggleStateChanged?.Invoke(value); } }