fix: ROSimulator registers multiple event handlers for state override buttons (#1203)

This commit is contained in:
bd_ 2024-09-23 20:27:56 -07:00 committed by GitHub
parent bf47a4c544
commit 51fedbd9b0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View File

@ -286,7 +286,7 @@ namespace nadena.dev.modular_avatar.core.editor.Simulator
// these properties in a closure // these properties in a closure
_menuItemOverrideProperty = prop; _menuItemOverrideProperty = prop;
_menuItemOverrideTarget = mami; _menuItemOverrideTarget = mami;
soc.OnStateOverrideChanged += MenuItemOverrideChanged; soc.OnStateOverrideChanged = MenuItemOverrideChanged;
} }
private void MenuItemOverrideChanged(bool? obj) private void MenuItemOverrideChanged(bool? obj)
@ -319,7 +319,7 @@ namespace nadena.dev.modular_avatar.core.editor.Simulator
_propertyOverrideProperty = property; _propertyOverrideProperty = property;
_propertyOverrideTargetValue = targetValue; _propertyOverrideTargetValue = targetValue;
soc.OnStateOverrideChanged += OnParameterOverrideChanged; soc.OnStateOverrideChanged = OnParameterOverrideChanged;
} }
private void OnParameterOverrideChanged(bool? state) private void OnParameterOverrideChanged(bool? state)
@ -539,11 +539,11 @@ namespace nadena.dev.modular_avatar.core.editor.Simulator
soc.SetWithoutNotify(menuOverride); soc.SetWithoutNotify(menuOverride);
} }
soc.OnStateOverrideChanged += value => { UpdateMenuItemOverride(prop, mami, value); }; soc.OnStateOverrideChanged = value => { UpdateMenuItemOverride(prop, mami, value); };
} }
else else
{ {
soc.OnStateOverrideChanged += value => UpdatePropertyOverride(prop, value, targetValue); soc.OnStateOverrideChanged = value => UpdatePropertyOverride(prop, value, targetValue);
} }
var active = condition.InitiallyActive; var active = condition.InitiallyActive;

View File

@ -16,7 +16,7 @@ namespace nadena.dev.modular_avatar.core.editor
private static StyleSheet uss; private static StyleSheet uss;
private Button btn_disable, btn_default, btn_enable; private Button btn_disable, btn_default, btn_enable;
public event System.Action<bool?> OnStateOverrideChanged; public System.Action<bool?> OnStateOverrideChanged;
public StateOverrideController() public StateOverrideController()
{ {