AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
TriggerButton.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
System
;
5
using
UnityEngine
;
6
7
namespace
HoloToolkit
.Unity.InputModule
8
{
12
public
class
TriggerButton
: MonoBehaviour,
IInputHandler
13
{
17
[Tooltip(
"Indicates whether the button is clickable or not."
)]
18
public
bool
IsEnabled =
true
;
19
20
public
event
Action
ButtonPressed
;
21
25
public
void
Press
()
26
{
27
if
(IsEnabled)
28
{
29
ButtonPressed.RaiseEvent();
30
}
31
}
32
33
void
IInputHandler
.
OnInputDown
(
InputEventData
eventData)
34
{
35
// Nothing.
36
}
37
38
void
IInputHandler
.
OnInputUp
(
InputEventData
eventData)
39
{
40
if
(IsEnabled && eventData.
PressType
==
InteractionSourcePressInfo
.Select)
41
{
42
ButtonPressed.RaiseEvent();
43
eventData.Use();
// Mark the event as used, so it doesn't fall through to other handlers.
44
}
45
}
46
}
47
}
HoloToolkit.Unity.InputModule.InteractionSourcePressInfo
InteractionSourcePressInfo
Definition:
InteractionSourcePressInfo.cs:6
System
HoloToolkit.Unity.InputModule.TriggerButton.ButtonPressed
Action ButtonPressed
Definition:
TriggerButton.cs:20
HoloToolkit.Unity.InputModule.TriggerButton
Very simple class that implements basic logic for a trigger button.
Definition:
TriggerButton.cs:12
HoloToolkit.Unity.InputModule.IInputHandler.OnInputUp
void OnInputUp(InputEventData eventData)
HoloToolkit.Unity.InputModule.TriggerButton.Press
void Press()
Press the button programmatically.
Definition:
TriggerButton.cs:25
HoloToolkit.Unity.InputModule.InputEventData.PressType
InteractionSourcePressInfo PressType
Button type that initiated the event.
Definition:
InputEventData.cs:16
HoloToolkit.Unity.InputModule.IInputHandler
Interface to implement to react to simple pointer-like input.
Definition:
IInputHandler.cs:11
HoloToolkit
HoloToolkit.Unity.InputModule.InputEventData
Describes an input event that has a source id and a press kind.
Definition:
InputEventData.cs:11
HoloToolkit.Unity.InputModule.IInputHandler.OnInputDown
void OnInputDown(InputEventData eventData)
UnityEngine
Assets
HoloToolkit
Input
Scripts
Utilities
Interactions
TriggerButton.cs
Generated by
1.8.12