Unity (C#)
The C# API for driving HEXR from Unity, as shipped in the com.microtube.hexr package.
Namespaces
Two namespaces matter. HexR holds the Unity components you add to scene objects; HaptGlove holds the low-level glove runtime, including the Haptics.Finger enum every actuation call takes.
PressureTrackerMain
The per-hand haptics controller. One lives on each Pressure Controller that HexR → Create HexR Rig drops into the scene — a left and a right. This is the class to call when you want direct control rather than physics-driven feedback.
CustomSingleHaptics(finger, states, targetPressure, speed, byPassHandCheck)
Steady pressure on one finger.
| Argument | Type | Description |
|---|---|---|
| finger | Haptics.Finger | Thumb, Index, Middle, Ring, Pinky, Palm |
| states | bool | true applies pressure, false releases it |
| targetPressure | float 0.1–1 | How hard — 0.1 is barely there, 1 is maximum |
| speed | float 0.1–1 | How fast it ramps to that pressure |
| byPassHandCheck | bool | true fires without checking whether a hand is near |
CustomSingleVibrations(finger, states, targetPressure, frequency, byPassHandCheck)
Vibration on one finger. Same arguments, except frequency (0.1–40) replaces speed.
Whole-hand calls
| Method | What it does |
|---|---|
TriggerAllHapticsIncrease(float) | Pressure on every channel at once |
TriggerCustomHapticsIncrease(bool[], float, float) | Pressure on a chosen subset of channels |
TriggerAllVibrations(float) | Vibration on every channel |
TriggerCustomlVibrations(bool[], float, float) | Vibration on a chosen subset |
TriggerPinchPressure(float) / RemovePinchPressure() | Thumb-and-index pinch pressure |
RemoveAllHaptics() / RemoveAllVibrations() | Clear everything |
Per-finger shorthands
SingleThumbHaptic(float), SingleIndexHaptic, SingleMiddleHaptic, SingleRingHaptic, SinglePinkyHaptic, SinglePalmHaptic, each with a matching Remove…Haptics(). Convenient for wiring straight into a UnityEvent in the inspector, since they take a single float.
IsHandNear()
Whether HEXR currently believes this hand is near something touchable. Every actuation call is gated on it unless you pass byPassHandCheck: true. It ORs three flags — grab-interactor hover, poke-interactor hover, and a ProximityCheck trigger volume — and on OpenXR only the last one is ever set.
Every actuation is gated on IsHandNear() unless you pass byPassHandCheck: true. If your calls appear to do nothing on OpenXR, the usual cause is a missing ProximityCheck on the object, not the hardware — see Make objects feel touchable.
HexRManager
Scene-level wiring and the Bluetooth connection flow. Reachable anywhere through the static HexRManager.Instance.
| Member | Description |
|---|---|
ConnectLeftBT() / ConnectRightBT() | Start the BLE connection for that hand. Safe to wire to a UI button |
leftHand / rightHand | The underlying HaptGloveHandler for each hand |
XRFramework | Which backend this scene targets — OpenXR or MetaOVR |
FingertipColliderRadius, PalmColliderSize | Size of the generated touch colliders |
RebindHandsToCurrentScene() | Re-resolve hand references after a scene load |
Scene components
Most projects never call the API directly — these components fire haptics from physics and events on their own.
HexRGrabbable
Makes an object pickable by the HEXR hands. Needs a Collider (trigger) and a Rigidbody on the same GameObject.
| Field | Description |
|---|---|
TypeOfGrab | PalmGrab needs the palm plus one finger; PinchGrab needs the thumb plus one finger |
Gravity | Whether gravity acts on the object once released |
HapticStrength | Feedback strength while held |
TheObject | Optional — separates the grab zone from the object that actually moves |
OnGrab / OnRelease | UnityEvents |
SpecialHaptics
Turns a trigger collider into a haptic zone. Set TypeOfHaptics to one of:
| Effect | Feels like |
|---|---|
CustomHaptics | Constant pressure while touched — HapticPressure sets the strength |
CustomVibrations | Vibration — VibrationsFrequencyValue and HapticStrenngthValue |
FountainEffect | Running water |
RainDropEffect | Raindrops, randomly triggered |
HeartBeatEffect | A beating heart — InTimer, OutTimer, regular or irregular |
HandSqueezeEffect | Fires OnSqueezeEventTrigger when the hand closes past SqueezeTightness |
HexRUsable
Fires WhenUseTriggerEvents once the fingers you marked Needed curl past UseThreshold, and WhenStopUsingTriggerEvents when they relax. Use it for triggers, handles and grips.
ProximityCheck
A trigger volume that tells HEXR a hand is near this object. Required on OpenXR — it is the only thing that sets the hand-near flag on that backend. Press Auto Set Up in its inspector to wire both Pressure Controllers.
HapticFingerTrigger
Sits on each fingertip and palm collider of the HEXR rig; Auto Setup Scene places these for you. Exposes TriggerFixPressure(float), TriggerVibrationPressure(float, float), RemoveVibration() and RemoveHaptics() if you need to drive one directly.
Example
A haptic zone that pulses the index finger on contact, then retunes a heartbeat effect when squeezed — the pattern the Tutorial Content sample uses:
using UnityEngine;
using HaptGlove;
using HexR;
public class TouchPulse : MonoBehaviour
{
public PressureTrackerMain hand; // Left or Right Pressure Controller
public SpecialHaptics heartbeat; // optional, a SpecialHaptics zone
void OnTriggerEnter(Collider other)
{
// finger, on, intensity 0.1-1, ramp speed 0.1-1, bypass the hand-near check
hand.CustomSingleHaptics(Haptics.Finger.Index, true, 0.8f, 1f, false);
}
void OnTriggerExit(Collider other)
{
hand.CustomSingleHaptics(Haptics.Finger.Index, false, 0f, 1f, false);
}
// Hook this to a HexRGrabbable OnGrab event
public void OnSqueeze()
{
heartbeat.InTimer = 0.2f;
heartbeat.OutTimer = 0.2f;
heartbeat.HapticStrenngthValue = 0.5f;
}
}This reference covers the components in com.microtube.hexr v0.4.0. The lower-level HaptGloveHandler API — BTConnection(), GetAirPressure(), GetBatteryLevel(), HEXRPressure(), HEXRVibration() — is documented in the tutorial repository.