A small utility class to easily add listeners to hmd/controllers events
-
Download and place the
ViveEventManager.cs
file in your "Assets" folder -
Create a new script in the GameObject you want to react on an event and add a listener function:
-
void FunctionName(ControllerEventObject evt)
for a controller event or -
void FunctionName(HMDEventObject evt)
for a HMD event
-
-
In the same GameObject, execute on
Awake()
(orStart()
) the following code:ViveEventManager.Instance.[Event] += [Listener];
-
You can use a "debug" mode that will print you the events as they occur and display the raycast from both controllers:
-
create an empty GameObject, add the script and select the "Debug Mode" or
-
at runtime, select "Debug Mode" on the "Event Manager" GameObject
-
OnTriggerPressStart
OnTriggerPress
OnTriggerPressEnd
OnTriggerClick
OnGripPressStart
OnGripPress
OnGripPressEnd
OnGripClick
, triggered if the delta time betweenOnGripPressStart
andOnGripPressEnd
is less than 300 milliseconds
OnTouchStart
OnTouchMove
OnTouchEnd
OnTouchTap
, triggered if the delta time betweenOnTouchStart
andOnTouchEnd
is less than 300 millisecondsOnSwipe
OnTouchpadPressStart
OnTouchpadPress
OnTouchpadPressEnd
OnTouchpadClick
, triggered if the delta time betweenOnTouchStart
andOnTouchEnd
is less than 300 milliseconds
- [to be added]
.side
returns "left" or "right".position
returns the position of the controller.rotation
returns the rotation of the controller.pressure
returns the pressure on the trigger (from 0.0f to 1.0f).isTriggerClicked
returnstrue
if the trigger has been clicked while it's still pressed.touchPoint
returns the finger's position on the touchpad, from -1.0f to 1.0f on both x- (left to right) and y-axis (bottom to top). Returns a Vector2.zero by default.swipeDirection
returns "+X" (left-to-right), "-X" (right-to-left), "+Y" (top-to-bottom), "-Y" (bottom-to-top). Returns "none" by default.controller
returns the controller object
- [to be added]
- add
OnPointerEnter
,OnPointerOver
,OnPointerLeave
events on the controllers using a raycast - add
OnLookEnter
,OnLookOver
,OnLookLeave
events on the HMD - add a Unity scene with an example
- switch to
UnityEvent
? To allow to add custom events in a centralized object ?