-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRightControllerAppearence.cs
executable file
·174 lines (147 loc) · 5.86 KB
/
RightControllerAppearence.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
using VRTK;
using UnityEngine;
/*
Author: Evan Otero
Date: Feb 10, 2017
RightControllerAppearence will manage all right controller events, actions, and tooltips.
TODO: We will also need a controller interact listener (separate class). See VRTK's example.
***********************
******* LICENSE *******
***********************
JoyceStick is a Boston College digital humanities project employing Unity
to construct a virtual reality game from Joyce’s Ulysses for viewing on the
HTC Vive, supported by a Teaching and Mentoring Grant and substantial funding
from internal bodies at Boston College.
Copyright (C) 2017 Evan Otero, Drew Hoo, Emaad Ali, Will Bowditch, Matt Harty, Jake Schafer, & Ryan Reede
http://joycestick.bc.edu/
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
public class RightControllerAppearence : MonoBehaviour
{
private VRTK_ControllerTooltips tooltips;
private VRTK_ControllerActions actions;
private VRTK_ControllerEvents events;
private bool ignoreEvents;
private void Start()
{
events = GetComponent<VRTK_ControllerEvents>();
actions = GetComponent<VRTK_ControllerActions>();
tooltips = GetComponentInChildren<VRTK_ControllerTooltips>();
// Setup Controller Event Listeners
events.TriggerPressed += new ControllerInteractionEventHandler(DoTriggerPressed);
events.TriggerReleased += new ControllerInteractionEventHandler(DoTriggerReleased);
events.ButtonOnePressed += new ControllerInteractionEventHandler(DoButtonOnePressed);
events.ButtonOneReleased += new ControllerInteractionEventHandler(DoButtonOneReleased);
events.GripPressed += new ControllerInteractionEventHandler(DoGripPressed);
events.GripReleased += new ControllerInteractionEventHandler(DoGripReleased);
events.TouchpadPressed += new ControllerInteractionEventHandler(DoTouchpadPressed);
events.TouchpadReleased += new ControllerInteractionEventHandler(DoTouchpadReleased);
tooltips.ToggleTips(false);
ignoreEvents = true;
}
public void toggleTriggerTooltips(bool state)
{
tooltips.ToggleTips(state, VRTK_ControllerTooltips.TooltipButtons.TriggerTooltip);
if (state)
{
actions.ToggleHighlightTrigger(true, Color.yellow, 0.5f);
actions.SetControllerOpacity(0.8f);
}
else
{
actions.ToggleHighlightTrigger(false);
actions.SetControllerOpacity(1f);
}
}
public void toggleButtonOneTooltips(bool state)
{
tooltips.ToggleTips(state, VRTK_ControllerTooltips.TooltipButtons.ButtonOneTooltip);
if (state)
{
actions.ToggleHighlightButtonOne(true, Color.yellow, 0.5f);
actions.SetControllerOpacity(0.8f);
}
else
{
actions.ToggleHighlightButtonOne(false);
actions.SetControllerOpacity(1f);
}
}
public void toggleGripTooltips(bool state)
{
tooltips.ToggleTips(state, VRTK_ControllerTooltips.TooltipButtons.GripTooltip);
if (state)
{
actions.ToggleHighlightGrip(true, Color.yellow, 0.5f);
actions.SetControllerOpacity(0.8f);
}
else
{
actions.ToggleHighlightGrip(false);
actions.SetControllerOpacity(1f);
}
}
public void toggleTouchpadTooltips(bool state)
{
tooltips.ToggleTips(state, VRTK_ControllerTooltips.TooltipButtons.TouchpadTooltip);
if (state)
{
actions.ToggleHighlightTouchpad(true, Color.yellow, 0.5f);
actions.SetControllerOpacity(0.8f);
}
else
{
actions.ToggleHighlightTouchpad(false);
actions.SetControllerOpacity(1f);
}
}
private void DoTriggerPressed(object sender, ControllerInteractionEventArgs e)
{
if (!ignoreEvents)
toggleTriggerTooltips(true);
}
private void DoTriggerReleased(object sender, ControllerInteractionEventArgs e)
{
if (!ignoreEvents)
toggleTriggerTooltips(false);
}
private void DoButtonOnePressed(object sender, ControllerInteractionEventArgs e)
{
if (!ignoreEvents)
toggleButtonOneTooltips(true);
}
private void DoButtonOneReleased(object sender, ControllerInteractionEventArgs e)
{
if (!ignoreEvents)
toggleButtonOneTooltips(false);
}
private void DoGripPressed(object sender, ControllerInteractionEventArgs e)
{
if (!ignoreEvents)
toggleGripTooltips(true);
}
private void DoGripReleased(object sender, ControllerInteractionEventArgs e)
{
if (!ignoreEvents)
toggleGripTooltips(false);
}
private void DoTouchpadPressed(object sender, ControllerInteractionEventArgs e)
{
if (!ignoreEvents)
toggleTouchpadTooltips(true);
}
private void DoTouchpadReleased(object sender, ControllerInteractionEventArgs e)
{
if (!ignoreEvents)
toggleTouchpadTooltips(false);
}
}