Skip to content

Commit ccceaf9

Browse files
author
David Kline
authored
Merge pull request #1919 from davidkline-ms/ux1827
changed if (enabled) -> if (enabled && !m_disabled) in OnInputDown, OnInputUp and OnInputClicked. added encapsulation of serialized fields per vNext coding style guidelines Fixes: #1827.
2 parents d297000 + bf01c44 commit ccceaf9

File tree

1 file changed

+24
-6
lines changed
  • Assets/HoloToolkit/UX/Scripts/Buttons

1 file changed

+24
-6
lines changed

Assets/HoloToolkit/UX/Scripts/Buttons/Button.cs

+24-6
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,38 @@ public abstract class Button : MonoBehaviour, IInputHandler, IPointerSpecificFoc
1919
/// Current Button State
2020
/// </summary>
2121
[Header("Basic Settings")]
22+
[SerializeField]
2223
[Tooltip("Current State of the Button")]
23-
public ButtonStateEnum ButtonState = ButtonStateEnum.Observation;
24+
private ButtonStateEnum buttonState = ButtonStateEnum.Observation;
25+
public ButtonStateEnum ButtonState
26+
{
27+
get { return buttonState; }
28+
set { buttonState = value; }
29+
}
2430

2531
/// <summary>
2632
/// Filter to apply for the correct button source
2733
/// </summary>
34+
[SerializeField]
2835
[Tooltip("Filter for press info for click or press event")]
29-
public InteractionSourcePressInfo ButtonPressFilter = InteractionSourcePressInfo.Select;
36+
private InteractionSourcePressInfo buttonPressFilter = InteractionSourcePressInfo.Select;
37+
public InteractionSourcePressInfo ButtonPressFilter
38+
{
39+
get { return buttonPressFilter; }
40+
set { buttonPressFilter = value; }
41+
}
3042

3143
/// <summary>
3244
/// If true the interactable will deselect when you look off of the object
3345
/// </summary>
46+
[SerializeField]
3447
[Tooltip("If RequireGaze then looking away will deselect object")]
35-
public bool RequireGaze = true;
48+
private bool requireGaze = true;
49+
public bool RequireGaze
50+
{
51+
get { return requireGaze; }
52+
set { requireGaze = value; }
53+
}
3654

3755
/// <summary>
3856
/// Event to receive button state change
@@ -114,7 +132,7 @@ public void TriggerClicked()
114132
/// <param name="eventData"></param>
115133
public void OnInputDown(InputEventData eventData)
116134
{
117-
if (enabled)
135+
if (enabled && !m_disabled)
118136
{
119137
if(ButtonPressFilter == InteractionSourcePressInfo.None || ButtonPressFilter == eventData.PressType)
120138
{
@@ -133,7 +151,7 @@ public void OnInputDown(InputEventData eventData)
133151
/// <param name="eventData"></param>
134152
public void OnInputUp(InputEventData eventData)
135153
{
136-
if (enabled)
154+
if (enabled && !m_disabled)
137155
{
138156
if (ButtonPressFilter == InteractionSourcePressInfo.None || ButtonPressFilter == eventData.PressType)
139157
{
@@ -148,7 +166,7 @@ public void OnInputUp(InputEventData eventData)
148166
/// <param name="eventData"></param>
149167
public void OnInputClicked(InputClickedEventData eventData)
150168
{
151-
if (enabled)
169+
if (enabled && !m_disabled)
152170
{
153171
if (ButtonPressFilter == InteractionSourcePressInfo.None || ButtonPressFilter == eventData.PressType)
154172
{

0 commit comments

Comments
 (0)