Skip to content

Commit

Permalink
Merge pull request #1919 from davidkline-ms/ux1827
Browse files Browse the repository at this point in the history
changed if (enabled) -> if (enabled && !m_disabled) in OnInputDown, OnInputUp and OnInputClicked.
added encapsulation of serialized fields per vNext coding style guidelines
Fixes: #1827.
  • Loading branch information
David Kline authored Apr 5, 2018
2 parents d297000 + bf01c44 commit ccceaf9
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions Assets/HoloToolkit/UX/Scripts/Buttons/Button.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,38 @@ public abstract class Button : MonoBehaviour, IInputHandler, IPointerSpecificFoc
/// Current Button State
/// </summary>
[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; }
}

/// <summary>
/// Filter to apply for the correct button source
/// </summary>
[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; }
}

/// <summary>
/// If true the interactable will deselect when you look off of the object
/// </summary>
[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; }
}

/// <summary>
/// Event to receive button state change
Expand Down Expand Up @@ -114,7 +132,7 @@ public void TriggerClicked()
/// <param name="eventData"></param>
public void OnInputDown(InputEventData eventData)
{
if (enabled)
if (enabled && !m_disabled)
{
if(ButtonPressFilter == InteractionSourcePressInfo.None || ButtonPressFilter == eventData.PressType)
{
Expand All @@ -133,7 +151,7 @@ public void OnInputDown(InputEventData eventData)
/// <param name="eventData"></param>
public void OnInputUp(InputEventData eventData)
{
if (enabled)
if (enabled && !m_disabled)
{
if (ButtonPressFilter == InteractionSourcePressInfo.None || ButtonPressFilter == eventData.PressType)
{
Expand All @@ -148,7 +166,7 @@ public void OnInputUp(InputEventData eventData)
/// <param name="eventData"></param>
public void OnInputClicked(InputClickedEventData eventData)
{
if (enabled)
if (enabled && !m_disabled)
{
if (ButtonPressFilter == InteractionSourcePressInfo.None || ButtonPressFilter == eventData.PressType)
{
Expand Down

0 comments on commit ccceaf9

Please sign in to comment.