diff --git a/Runtime/Input/InteractionBehaviours/ButtonBehaviour.cs b/Runtime/Input/InteractionBehaviours/ButtonBehaviour.cs index 386b7d17..dfa641a4 100644 --- a/Runtime/Input/InteractionBehaviours/ButtonBehaviour.cs +++ b/Runtime/Input/InteractionBehaviours/ButtonBehaviour.cs @@ -34,18 +34,36 @@ public class ButtonClickEvent : UnityEvent { } public ButtonClickEvent Click => click; /// - protected override void OnSelectEntered(InteractionEventArgs eventArgs) + protected override void OnFirstSelectEntered(InteractionEventArgs eventArgs) { - if (raiseOnInputDown) + if (raiseOnInputDown && !Interactable.IsGrabbed) { Click?.Invoke(); } } /// - protected override void OnSelectExited(InteractionExitEventArgs eventArgs) + protected override void OnLastSelectExited(InteractionExitEventArgs eventArgs) { - if (!raiseOnInputDown) + if (!raiseOnInputDown && !Interactable.IsGrabbed) + { + Click?.Invoke(); + } + } + + /// + protected override void OnFirstGrabEntered(InteractionEventArgs eventArgs) + { + if (raiseOnInputDown && !Interactable.IsSelected) + { + Click?.Invoke(); + } + } + + /// + protected override void OnLastGrabExited(InteractionExitEventArgs eventArgs) + { + if (!raiseOnInputDown && !Interactable.IsSelected) { Click?.Invoke(); } diff --git a/Runtime/Input/InteractionBehaviours/ToggleBehaviour.cs b/Runtime/Input/InteractionBehaviours/ToggleBehaviour.cs index f66e80c5..8c8b9dc9 100644 --- a/Runtime/Input/InteractionBehaviours/ToggleBehaviour.cs +++ b/Runtime/Input/InteractionBehaviours/ToggleBehaviour.cs @@ -61,18 +61,36 @@ public bool IsOn public void SetIsOnWithoutNotify(bool isOn) => this.isOn = isOn; /// - protected override void OnSelectEntered(InteractionEventArgs eventArgs) + protected override void OnFirstSelectEntered(InteractionEventArgs eventArgs) { - if (raiseOnInputDown) + if (raiseOnInputDown && !Interactable.IsGrabbed) { IsOn = !IsOn; } } /// - protected override void OnSelectExited(InteractionExitEventArgs eventArgs) + protected override void OnLastSelectExited(InteractionExitEventArgs eventArgs) { - if (!raiseOnInputDown) + if (!raiseOnInputDown && !Interactable.IsGrabbed) + { + IsOn = !IsOn; + } + } + + /// + protected override void OnFirstGrabEntered(InteractionEventArgs eventArgs) + { + if (raiseOnInputDown && !Interactable.IsSelected) + { + IsOn = !IsOn; + } + } + + /// + protected override void OnLastGrabExited(InteractionExitEventArgs eventArgs) + { + if (!raiseOnInputDown && !Interactable.IsSelected) { IsOn = !IsOn; }