From bf01c441e0e6e7168341f9ad05ae45bb34fb9624 Mon Sep 17 00:00:00 2001 From: "David Kline (ANALOG)" Date: Thu, 5 Apr 2018 11:26:06 -0700 Subject: [PATCH] fix #1827 (disabled state handling) --- .../HoloToolkit/UX/Scripts/Buttons/Button.cs | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/Assets/HoloToolkit/UX/Scripts/Buttons/Button.cs b/Assets/HoloToolkit/UX/Scripts/Buttons/Button.cs index 744b1dfcd69..5f92fb408d1 100644 --- a/Assets/HoloToolkit/UX/Scripts/Buttons/Button.cs +++ b/Assets/HoloToolkit/UX/Scripts/Buttons/Button.cs @@ -19,20 +19,38 @@ public abstract class Button : MonoBehaviour, IInputHandler, IPointerSpecificFoc /// Current Button State /// [Header("Basic Settings")] + [SerializeField] [Tooltip("Current State of the Button")] - public ButtonStateEnum ButtonState = ButtonStateEnum.Observation; + private ButtonStateEnum buttonState = ButtonStateEnum.Observation; + public ButtonStateEnum ButtonState + { + get { return buttonState; } + set { buttonState = value; } + } /// /// Filter to apply for the correct button source /// + [SerializeField] [Tooltip("Filter for press info for click or press event")] - public InteractionSourcePressInfo ButtonPressFilter = InteractionSourcePressInfo.Select; + private InteractionSourcePressInfo buttonPressFilter = InteractionSourcePressInfo.Select; + public InteractionSourcePressInfo ButtonPressFilter + { + get { return buttonPressFilter; } + set { buttonPressFilter = value; } + } /// /// If true the interactable will deselect when you look off of the object /// + [SerializeField] [Tooltip("If RequireGaze then looking away will deselect object")] - public bool RequireGaze = true; + private bool requireGaze = true; + public bool RequireGaze + { + get { return requireGaze; } + set { requireGaze = value; } + } /// /// Event to receive button state change @@ -114,7 +132,7 @@ public void TriggerClicked() /// public void OnInputDown(InputEventData eventData) { - if (enabled) + if (enabled && !m_disabled) { if(ButtonPressFilter == InteractionSourcePressInfo.None || ButtonPressFilter == eventData.PressType) { @@ -133,7 +151,7 @@ public void OnInputDown(InputEventData eventData) /// public void OnInputUp(InputEventData eventData) { - if (enabled) + if (enabled && !m_disabled) { if (ButtonPressFilter == InteractionSourcePressInfo.None || ButtonPressFilter == eventData.PressType) { @@ -148,7 +166,7 @@ public void OnInputUp(InputEventData eventData) /// public void OnInputClicked(InputClickedEventData eventData) { - if (enabled) + if (enabled && !m_disabled) { if (ButtonPressFilter == InteractionSourcePressInfo.None || ButtonPressFilter == eventData.PressType) {