cancel
Showing results for 
Search instead for 
Did you mean: 

Eye Tracking issue with Meta Quest Pro in Unity (Meta Core SDK)

curby.980441
Honored Guest

Hello,

I am working on a Unity VR project and I am currently using the Meta Quest Pro. I want to collect eye and facial data from the user so I created a script to access the data from OVREyeGaze, but I keep receiving this same error of the Eye tracking not being enabled (checking if OVR.eyeTrackingEnabled is true). I have checked the necessary boxes in OVRManager and enabled the beta settings for the Eye tracking and in the Meta Quest Pro's settings. Please let me know if I am doing anything wrong or if I missed something. I would be more than happy to provide more information.  I will attach my code for the eyetracking.

using System;
using System.IO;
using UnityEngine;

/// <summary>
/// Logs eye tracking data from OVRPlugin to a CSV file.
/// </summary>
public class EyeTrackingLogger : MonoBehaviour
{
    public string LogFileName = "EyeTrackingLog.csv"; // File to save logs
    public float LogInterval = 0.1f; // Time between log entries in seconds

    private float _nextLogTime;
    private StreamWriter _csvWriter;
    private bool _isLogging;

    void Start()
    {
        // Automatically start logging when the game starts
        StartLogging();
    }

    void Update()
    {
        // Log data periodically based on LogInterval
        if (_isLogging && Time.time >= _nextLogTime)
        {
            LogEyeData();
            _nextLogTime = Time.time + LogInterval;
        }
    }

    void OnDestroy()
    {
        // Stop logging and clean up resources when the object is destroyed
        StopLogging();
    }

    /// <summary>
    /// Starts logging eye-tracking data to the CSV file.
    /// </summary>
    private void StartLogging()
    {
        if (!OVRPlugin.eyeTrackingEnabled)
        {
            Debug.LogError("Eye tracking is not enabled. Ensure it is configured in the Oculus settings.");
            return;
        }

        try
        {
            _csvWriter = new StreamWriter(LogFileName);
            _csvWriter.WriteLine("Timestamp,Eye,Confidence,PositionX,PositionY,PositionZ,RotationX,RotationY,RotationZ,RotationW");
            _isLogging = true;
            Debug.Log($"Eye tracking logging started. Writing to: {LogFileName}");
        }
        catch (Exception e)
        {
            Debug.LogError($"Failed to start logging: {e.Message}");
        }
    }

    /// <summary>
    /// Stops logging and closes the CSV file.
    /// </summary>
    private void StopLogging()
    {
        if (_csvWriter != null)
        {
            _csvWriter.Close();
            _csvWriter = null;
        }

        _isLogging = false;
        Debug.Log("Eye tracking logging stopped.");
    }

    /// <summary>
    /// Logs the current eye-tracking data.
    /// </summary>
    private void LogEyeData()
    {
        var eyeGazesState = new OVRPlugin.EyeGazesState();
        if (!OVRPlugin.GetEyeGazesState(OVRPlugin.Step.Render, -1, ref eyeGazesState))
        {
            Debug.LogWarning("Failed to retrieve eye-gaze state.");
            return;
        }

        foreach (OVRPlugin.Eye eye in Enum.GetValues(typeof(OVRPlugin.Eye)))
        {
            var eyeGaze = eyeGazesState.EyeGazes[(int)eye];

            if (!eyeGaze.IsValid || eyeGaze.Confidence < 0.5f) // Adjust confidence threshold as needed
            {
                continue;
            }

            var position = eyeGaze.Pose.Position;
            var rotation = eyeGaze.Pose.Orientation;
            string logEntry = $"{Time.time},{eye},{eyeGaze.Confidence},{position.x},{position.y},{position.z},{rotation.x},{rotation.y},{rotation.z},{rotation.w}";

            _csvWriter.WriteLine(logEntry);
        }

        _csvWriter.Flush(); // Ensure data is written to the file immediately
    }
}





3 REPLIES 3

MetaQuestSupport
Community Manager
Community Manager

Hi @curby.980441 

 

Thank you so much for reaching out with your eye tracking issue.

 

We would advise that in order to get the most appropriate support to go through the link we have provided here to get in touch with our developer support as they have further access we don't in order to troubleshoot any issues that can occur with development tools and systems and so should be able to look over the issue with you in order to find the root cause of the problem and then explore possible resolutions to it!

If you're the author of a thread, remember to mark a reply as the Accepted Solution to help others find answers!

I posted a community post on there and received no response. When i try to load the page sent to me it doesn't seem to fully load? I've tried everything to fix this issue but I am unsure what is wrong. Is there a way to contact someone to fix my issue?

 

Hi again!

 

We wouldn't be able to give a direct contact of a representative from Meta Quest Developer support however, we'd request you to go to Meta Quest Developer Support page in order to get any assistance in this issue.

 

Thank you for your patience and understanding once again!

If you're the author of a thread, remember to mark a reply as the Accepted Solution to help others find answers!
Still need help?

Did this answer your question? If it didn’t, use our search to find other topics or create your own and other members of the community will help out.

If you need an agent to help with your Meta device, please contact our store support team here.

Having trouble with a Facebook or Instagram account? The best place to go for help with those accounts is the Facebook Help Center or the Instagram Help Center. This community can't help with those accounts.

Check out some popular posts here:

Getting Help from the Meta Quest Community

Tips and Tricks: Charging your Meta Quest Headset

Tips and Tricks: Help with Pairing your Meta Quest

Trouble With Facebook/Instagram Accounts?