From 51fedbd9b01aebb3700f8ced70652985d4b770f2 Mon Sep 17 00:00:00 2001 From: bd_ Date: Mon, 23 Sep 2024 20:27:56 -0700 Subject: [PATCH] fix: ROSimulator registers multiple event handlers for state override buttons (#1203) --- Editor/ReactiveObjects/Simulator/ROSimulator.cs | 8 ++++---- .../ReactiveObjects/Simulator/StateOverrideController.cs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Editor/ReactiveObjects/Simulator/ROSimulator.cs b/Editor/ReactiveObjects/Simulator/ROSimulator.cs index d4188fbc..e34a7a40 100644 --- a/Editor/ReactiveObjects/Simulator/ROSimulator.cs +++ b/Editor/ReactiveObjects/Simulator/ROSimulator.cs @@ -286,7 +286,7 @@ namespace nadena.dev.modular_avatar.core.editor.Simulator // these properties in a closure _menuItemOverrideProperty = prop; _menuItemOverrideTarget = mami; - soc.OnStateOverrideChanged += MenuItemOverrideChanged; + soc.OnStateOverrideChanged = MenuItemOverrideChanged; } private void MenuItemOverrideChanged(bool? obj) @@ -319,7 +319,7 @@ namespace nadena.dev.modular_avatar.core.editor.Simulator _propertyOverrideProperty = property; _propertyOverrideTargetValue = targetValue; - soc.OnStateOverrideChanged += OnParameterOverrideChanged; + soc.OnStateOverrideChanged = OnParameterOverrideChanged; } private void OnParameterOverrideChanged(bool? state) @@ -539,11 +539,11 @@ namespace nadena.dev.modular_avatar.core.editor.Simulator soc.SetWithoutNotify(menuOverride); } - soc.OnStateOverrideChanged += value => { UpdateMenuItemOverride(prop, mami, value); }; + soc.OnStateOverrideChanged = value => { UpdateMenuItemOverride(prop, mami, value); }; } else { - soc.OnStateOverrideChanged += value => UpdatePropertyOverride(prop, value, targetValue); + soc.OnStateOverrideChanged = value => UpdatePropertyOverride(prop, value, targetValue); } var active = condition.InitiallyActive; diff --git a/Editor/ReactiveObjects/Simulator/StateOverrideController.cs b/Editor/ReactiveObjects/Simulator/StateOverrideController.cs index 1e05122f..74d9c45e 100644 --- a/Editor/ReactiveObjects/Simulator/StateOverrideController.cs +++ b/Editor/ReactiveObjects/Simulator/StateOverrideController.cs @@ -16,7 +16,7 @@ namespace nadena.dev.modular_avatar.core.editor private static StyleSheet uss; private Button btn_disable, btn_default, btn_enable; - public event System.Action OnStateOverrideChanged; + public System.Action OnStateOverrideChanged; public StateOverrideController() {