AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
InputTest.cs
Go to the documentation of this file.
1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // Licensed under the MIT License. See LICENSE in the project root for license information.
3 
4 using UnityEngine;
5 using UnityEngine.EventSystems;
6 
7 namespace HoloToolkit.Unity.InputModule.Tests
8 {
14  {
15  [Tooltip("Set to true if gestures update (ManipulationUpdated, NavigationUpdated) should be logged. Note that this can impact performance.")]
16  public bool LogGesturesUpdateEvents = false;
17 
18  public void OnInputUp(InputEventData eventData)
19  {
20  Debug.LogFormat("OnInputUp\r\nSource: {0} SourceId: {1} InteractionPressKind: {2}", eventData.InputSource, eventData.SourceId, eventData.PressType);
21  eventData.Use(); // Mark the event as used, so it doesn't fall through to other handlers.
22  }
23 
24  public void OnInputDown(InputEventData eventData)
25  {
26  Debug.LogFormat("OnInputDown\r\nSource: {0} SourceId: {1} InteractionPressKind: {2}", eventData.InputSource, eventData.SourceId, eventData.PressType);
27  eventData.Use(); // Mark the event as used, so it doesn't fall through to other handlers.
28  }
29 
30  public void OnInputClicked(InputClickedEventData eventData)
31  {
32  Debug.LogFormat("OnInputClicked\r\nSource: {0} SourceId: {1} InteractionPressKind: {2} TapCount: {3}", eventData.InputSource, eventData.SourceId, eventData.PressType, eventData.TapCount);
33  eventData.Use(); // Mark the event as used, so it doesn't fall through to other handlers.
34  }
35 
39  public void OnPointerClick(PointerEventData pointerEventData)
40  {
41  Debug.Log("OnPointerClick: " + pointerEventData.pointerId);
42  }
43 
44  public void OnFocusEnter()
45  {
46  Debug.Log("OnFocusEnter");
47  }
48 
49  public void OnFocusExit()
50  {
51  Debug.Log("OnFocusExit");
52  }
53 
54  public void OnSourceDetected(SourceStateEventData eventData)
55  {
56  Debug.LogFormat("OnSourceDetected\r\nSource: {0} SourceId: {1}", eventData.InputSource, eventData.SourceId);
57  eventData.Use(); // Mark the event as used, so it doesn't fall through to other handlers.
58  }
59 
60  public void OnSourceLost(SourceStateEventData eventData)
61  {
62  Debug.LogFormat("OnSourceLost\r\nSource: {0} SourceId: {1}", eventData.InputSource, eventData.SourceId);
63  eventData.Use(); // Mark the event as used, so it doesn't fall through to other handlers.
64  }
65 
66  public void OnHoldStarted(HoldEventData eventData)
67  {
68  Debug.LogFormat("OnHoldStarted\r\nSource: {0} SourceId: {1}", eventData.InputSource, eventData.SourceId);
69  eventData.Use(); // Mark the event as used, so it doesn't fall through to other handlers.
70  }
71 
72  public void OnHoldCompleted(HoldEventData eventData)
73  {
74  Debug.LogFormat("OnHoldCompleted\r\nSource: {0} SourceId: {1}", eventData.InputSource, eventData.SourceId);
75  eventData.Use(); // Mark the event as used, so it doesn't fall through to other handlers.
76  }
77 
78  public void OnHoldCanceled(HoldEventData eventData)
79  {
80  Debug.LogFormat("OnHoldCanceled\r\nSource: {0} SourceId: {1}", eventData.InputSource, eventData.SourceId);
81  eventData.Use(); // Mark the event as used, so it doesn't fall through to other handlers.
82  }
83 
85  {
86  Debug.LogFormat("OnManipulationStarted\r\nSource: {0} SourceId: {1}\r\nCumulativeDelta: {2} {3} {4}",
87  eventData.InputSource,
88  eventData.SourceId,
89  eventData.CumulativeDelta.x,
90  eventData.CumulativeDelta.y,
91  eventData.CumulativeDelta.z);
92 
93  eventData.Use(); // Mark the event as used, so it doesn't fall through to other handlers.
94  }
95 
97  {
98  if (LogGesturesUpdateEvents)
99  {
100  Debug.LogFormat("OnManipulationUpdated\r\nSource: {0} SourceId: {1}\r\nCumulativeDelta: {2} {3} {4}",
101  eventData.InputSource,
102  eventData.SourceId,
103  eventData.CumulativeDelta.x,
104  eventData.CumulativeDelta.y,
105  eventData.CumulativeDelta.z);
106 
107  eventData.Use(); // Mark the event as used, so it doesn't fall through to other handlers.
108  }
109  }
110 
112  {
113  Debug.LogFormat("OnManipulationCompleted\r\nSource: {0} SourceId: {1}\r\nCumulativeDelta: {2} {3} {4}",
114  eventData.InputSource,
115  eventData.SourceId,
116  eventData.CumulativeDelta.x,
117  eventData.CumulativeDelta.y,
118  eventData.CumulativeDelta.z);
119 
120  eventData.Use(); // Mark the event as used, so it doesn't fall through to other handlers.
121  }
122 
124  {
125  Debug.LogFormat("OnManipulationCanceled\r\nSource: {0} SourceId: {1}\r\nCumulativeDelta: {2} {3} {4}",
126  eventData.InputSource,
127  eventData.SourceId,
128  eventData.CumulativeDelta.x,
129  eventData.CumulativeDelta.y,
130  eventData.CumulativeDelta.z);
131 
132  eventData.Use(); // Mark the event as used, so it doesn't fall through to other handlers.
133  }
134 
136  {
137  Debug.LogFormat("OnNavigationStarted\r\nSource: {0} SourceId: {1}\r\nCumulativeDelta: {2} {3} {4}",
138  eventData.InputSource,
139  eventData.SourceId,
140  eventData.NormalizedOffset.x,
141  eventData.NormalizedOffset.y,
142  eventData.NormalizedOffset.z);
143 
144  eventData.Use(); // Mark the event as used, so it doesn't fall through to other handlers.
145  }
146 
148  {
149  if (LogGesturesUpdateEvents)
150  {
151  Debug.LogFormat("OnNavigationUpdated\r\nSource: {0} SourceId: {1}\r\nCumulativeDelta: {2} {3} {4}",
152  eventData.InputSource,
153  eventData.SourceId,
154  eventData.NormalizedOffset.x,
155  eventData.NormalizedOffset.y,
156  eventData.NormalizedOffset.z);
157 
158  eventData.Use(); // Mark the event as used, so it doesn't fall through to other handlers.
159  }
160  }
161 
163  {
164  Debug.LogFormat("OnNavigationCompleted\r\nSource: {0} SourceId: {1}\r\nCumulativeDelta: {2} {3} {4}",
165  eventData.InputSource,
166  eventData.SourceId,
167  eventData.NormalizedOffset.x,
168  eventData.NormalizedOffset.y,
169  eventData.NormalizedOffset.z);
170 
171  eventData.Use(); // Mark the event as used, so it doesn't fall through to other handlers.
172  }
173 
175  {
176  Debug.LogFormat("OnNavigationCanceled\r\nSource: {0} SourceId: {1}\r\nCumulativeDelta: {2} {3} {4}",
177  eventData.InputSource,
178  eventData.SourceId,
179  eventData.NormalizedOffset.x,
180  eventData.NormalizedOffset.y,
181  eventData.NormalizedOffset.z);
182 
183  eventData.Use(); // Mark the event as used, so it doesn't fall through to other handlers.
184  }
185  }
186 }
void OnInputDown(InputEventData eventData)
Definition: InputTest.cs:24
void OnInputUp(InputEventData eventData)
Definition: InputTest.cs:18
void OnSourceLost(SourceStateEventData eventData)
Definition: InputTest.cs:60
int TapCount
Number of taps that triggered the event.
void OnNavigationCanceled(NavigationEventData eventData)
Definition: InputTest.cs:174
void OnNavigationStarted(NavigationEventData eventData)
Definition: InputTest.cs:135
uint SourceId
The id of the source the event is from, for instance the hand id.
void OnNavigationCompleted(NavigationEventData eventData)
Definition: InputTest.cs:162
void OnManipulationCanceled(ManipulationEventData eventData)
Definition: InputTest.cs:123
Describes an input event that involves content manipulation.
Interface to implement to react to navigation gestures.
void OnManipulationStarted(ManipulationEventData eventData)
Definition: InputTest.cs:84
void OnHoldCanceled(HoldEventData eventData)
Definition: InputTest.cs:78
Vector3 CumulativeDelta
The amount of manipulation that has occurred. Usually in the form of delta position of a hand...
IInputSource InputSource
The source the input event originates from.
Interface to implement to react to simple click input.
void OnSourceDetected(SourceStateEventData eventData)
Definition: InputTest.cs:54
Describes an input event that involves content navigation.
Interface to implement to react to hold gestures.
Definition: IHoldHandler.cs:11
void OnManipulationUpdated(ManipulationEventData eventData)
Definition: InputTest.cs:96
Vector3 NormalizedOffset
The amount of manipulation that has occurred. Sent in the form of a normalized offset of a hand...
Interface to implement to react to source state changes, such as when an input source is detected or ...
Interface to implement to react to focus enter/exit.
Definition: IFocusable.cs:11
void OnManipulationCompleted(ManipulationEventData eventData)
Definition: InputTest.cs:111
InteractionSourcePressInfo PressType
Button type that initiated the event.
void OnNavigationUpdated(NavigationEventData eventData)
Definition: InputTest.cs:147
Describes an input event that involves a tap.
Interface to implement to react to simple pointer-like input.
void OnInputClicked(InputClickedEventData eventData)
Definition: InputTest.cs:30
void OnPointerClick(PointerEventData pointerEventData)
Just a public method called by the Unity OnClick Event.
Definition: InputTest.cs:39
Test MonoBehaviour that simply prints out a message very time a supported event is received from the ...
Definition: InputTest.cs:13
Describes an source state event that has a source id.
Event dispatched when a hold gesture is detected.
void OnHoldStarted(HoldEventData eventData)
Definition: InputTest.cs:66
void OnHoldCompleted(HoldEventData eventData)
Definition: InputTest.cs:72
Describes an input event that has a source id and a press kind.
Interface to implement to react to manipulation gestures.