OVRPlugin exposes this pose along with a validity flag and a timestamp, so your app can drive gaze-based selection, targeting, and pointing from one direction vector.OVRCameraRig, the OVRManager target devices and Quest features, eye tracking support and permissions, and the Project Setup Tool. Both eye tracking APIs share that setup.OVRPlugin are public in the Meta XR Core SDK for Unity starting with the v207 release. Earlier SDK versions keep these members internal, so target v207 or newer to call them.OVRPlugin:| Member | Description |
|---|---|
eyeGazeInteractionsSupported | Returns true when the device and runtime support eye gaze interaction. |
eyeGazeInteractionsEnabled | Returns true when eye gaze interaction is enabled, which reflects the user’s eye tracking permission. |
eyeGazeInteractionsSupported reflects the hardware and runtime. eyeGazeInteractionsEnabled reflects the user’s permission grant. A device that supports eye tracking still returns no pose until the user grants permission.GetEyeGazeInteractionState to populate an EyeGazeInteractionState struct for the current frame:public static bool GetEyeGazeInteractionState(
Step stepId, int frameIndex, ref EyeGazeInteractionState eyeGazeInteractionState)
true when it retrieves a state and false otherwise. Pass -1 for frameIndex to query the current frame. The populated EyeGazeInteractionState exposes these public members:| Member | Kind | Type | Description |
|---|---|---|---|
Pose | Field | Posef | The eye gaze interaction pose, as a position and orientation. |
IsValid | Read-only property | bool | Returns true when the gaze pose is valid. Check this before you use Pose. |
Time | Field | double | The timestamp associated with the state. |
IsValid is computed from an internal flag, so you read it but do not assign it. Pose and Time are fields.true return from GetEyeGazeInteractionState means the call succeeded, not that the pose is usable. Read IsValid and act on Pose only when it is true.GetEyeGazeInteractionState takes a Step that names which tracking step to query. Under OpenXR, Step.Physics is deprecated. When the runtime is OpenXR and you pass Step.Physics, OVRPlugin logs a warning and reads Step.Render instead. Pass Step.Render to avoid the warning.void Update()
{
if (!OVRPlugin.eyeGazeInteractionsSupported || !OVRPlugin.eyeGazeInteractionsEnabled)
{
return;
}
var state = new OVRPlugin.EyeGazeInteractionState();
if (OVRPlugin.GetEyeGazeInteractionState(OVRPlugin.Step.Render, -1, ref state) && state.IsValid)
{
OVRPlugin.Posef gazePose = state.Pose;
double timestamp = state.Time;
// Drive gaze-based interaction from gazePose and timestamp.
}
}