Usage

Please complete steps in the Setup section before running your application.

The main interfaces are provided in the singleton class GestureProvider. Please ensure one and only one script is attached in the scene. The detection results are stored in GestureResult class.

Note

Vive Hand Tracking SDK requires real camera devices to function, therefore does not support running in Unity Editor for platforms other than Windows.

Add Script to the Scene

To use Vive Hand Tracking SDK in your Unity project, add GestureProvider script to your VR render camera and set options in Inspector.

  • For most scenes, this normally is the camera object with MainCamera tag.
  • If you are using other VR plugins, this may be the head object in the camera prefab.
../_images/backend.png ../_images/mode.png

Note

GestureProvider script must be attached to your VR render camera, or an object that has same position & rotation of your VR render camera.

The transform of GestureProvider is used to make sure detected hand position are in the correct global coordinate system. Most games add extra position/rotation offset to your rendering camera, please make sure the same offset is add to the object GestureProvider attached.

Two sample scenes are included in the plugin to demonstrate how to add GestureProvider script.

Start/Stop detection

GestureProvider handles detection start and stop based on its lifecycle. Detection is started when the script is enabled and stopped when the script is disabled/destroyed. The results are cleared when detection stops.

To manually control start/stop of the detection, simply enable/disable the script:

GestureProvider.Current.enabled = true;  // enable the script to start the detection
GestureProvider.Current.enabled = false; // disable the script to stop the detection

Android Camera Permission

On Android/WaveVR platform, camera permission must be granted before starting the detection. Vive Hand Tracking SDK automatically handles camera permission for WaveVR and Daydream. But on most Android phones, Unity does not support runtime permission before 2018.3. In such cases, you need to add your own logic (or using other Unity plugins) to grant camera permission. Make sure GestureProvider is disabled at startup, grant camera permission, and enable GestureProvider.

Getting Detection Result

When detection is running, detectioned hand results are available as GestureProvider.LeftHand and GestureProvider.RightHand. Each hand contains pre-defined gesture and position of the hand. Positions has different meanings for each mode selected. See Samples section and GestureResult class for details.

To query current detection mode and status, use GestureProvider.Mode and GestureProvider.Status.

To query if gesture results are updated in this frame, use GestureProvider.UpdatedInThisFrame.