Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Accessing EyeTracking Device on Hololens 2

Discussion in 'VR' started by cloera1, Jul 2, 2020.

  1. cloera1

    cloera1

    Joined:
    Jul 2, 2020
    Posts:
    4
    I have a Unity 2019.4 client application for the Hololens 2 that needs to access eye tracking data from Unity's Eyes API. That data will then be sent to a server application that will process the eye tracking data from the client.

    Right now I am not able to see any eye tracking device when I get a list of InputDevices. I can only see my WindowsMR Headset and Hand when I print the list of InputDevices available. I enabled the GazeInput capability within Unity and the prompt to get permission to use eye tracking shows up in my headset. I don't have MRTK installed on my client and I can't install it for this application which is why its crucial for me to use the Eyes API from Unity.

    Is there something that I'm missing that is preventing the eye tracking device from showing up?

    Any help will be greatly appreciated!


    Here is my code for accessing the list of InputDevices:

    Code (CSharp):
    1.     void OnEnable()
    2.     {
    3.         List<InputDevice> devices = new List<InputDevice>();
    4.         InputDevices.GetDevices(devices);
    5.  
    6.         foreach(InputDevice device in devices)
    7.         {
    8.             Debug.Log("Device name " + device.name + " with characteristics " + device.characteristics.ToString());
    9.         }
    10.     }
     
  2. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    Is this using built in VR or the new XR Plug-in model?
     
  3. cloera1

    cloera1

    Joined:
    Jul 2, 2020
    Posts:
    4
    It's using the XR Plug-in model
     
  4. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    cloera1 likes this.
  5. cloera1

    cloera1

    Joined:
    Jul 2, 2020
    Posts:
    4
    Thank you! That was very helpful! My problem was that I was looking for a device with the characteristic EyeTracking, but the WindowsMR Headset had the EyeGaze features the whole time.

    This was my code to see if EyeGazeAvailable feature was active:

    Code (CSharp):
    1. List<InputDevice> devices = new List<InputDevice>();
    2.         InputDevices.GetDevices(devices);
    3.  
    4.         bool inputValue;
    5.  
    6.         foreach (InputDevice device in devices)
    7.         {
    8.             if (device.TryGetFeatureValue(WindowsMRUsages.EyeGazeAvailable, out inputValue))
    9.             {
    10.                 Debug.Log("Device name: " + device.name + " EyeGazeAvailable: " + inputValue);
    11.             }
    12.         }

    And this is what it printed out:

    Device name: WindowsMR Headset() EyeGazeAvailable: True
     
  6. cloera1

    cloera1

    Joined:
    Jul 2, 2020
    Posts:
    4
    @joejo Is it possible to use these eye gaze features or any other available Unity eye tracking APIs for Hololens 2 with Built-in XR enabled instead of the XR Plugin model?

    Thanks again for your help!