# Eye Tracking Unity API

**URL:** https://forum.magicleap.cloud/t/eye-tracking-unity-api/2863
**Category:** Unity Development
**Tags:** unity
**Created:** [November 13, 2023, 12:58am UTC](https://forum.magicleap.cloud/t/eye-tracking-unity-api/2863 "2023-11-13T00:58:00Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![zhhqu0305](https://avatars.discourse-cdn.com/v4/letter/z/a9a28c/32.png) [@zhhqu0305](https://forum.magicleap.cloud/u/zhhqu0305)
#### Post date: [November 13, 2023, 12:58am UTC](https://forum.magicleap.cloud/t/eye-tracking-unity-api/2863/1 "2023-11-13T00:58:00Z")

</div>

I'm using the Unity eye-tracking API to collect data. It is said that left/right pupil size could be returned by

```auto
eyesActions.Data.ReadValue<UnityEngine.InputSystem.XR.Eyes>().leftEyeOpenAmount

```

which is a float value between 0 and 1. May I ask what this value stands for exactly? Is it a proportion out of some kind of full-size, or is it a absolute value, that would be very different if measured on different individuals?

Thanks in advance!

---

<div class="post-metadata">

### Author: ![kbabilinski](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/kbabilinski/32/19_2.png) [@kbabilinski](https://forum.magicleap.cloud/u/kbabilinski)
#### Post date: [November 14, 2023, 4:23am UTC](https://forum.magicleap.cloud/t/eye-tracking-unity-api/2863/2 "2023-11-14T04:23:29Z")

</div>

Thank you for reporting this issue. The documentation is incorrect with eye open amount is measuring the eyelid separation. The value of 1 representing the most open. That said, we are working on integrating eye pupil size in future releases.

Do you mind sharing more information about your application and implementation so we can provide details to our voice of customer team?

---

<div class="post-metadata">

### Author: ![zhhqu0305](https://avatars.discourse-cdn.com/v4/letter/z/a9a28c/32.png) [@zhhqu0305](https://forum.magicleap.cloud/u/zhhqu0305)
#### Post date: [November 14, 2023, 3:09pm UTC](https://forum.magicleap.cloud/t/eye-tracking-unity-api/2863/3 "2023-11-14T15:09:59Z")

</div>

Thanks for your reply! Right now we are collecting eye-tracking data only for research purpose. You are saying that, this `OpenAmount` variable is specifying the proportion of eye open? So that it's insensitive to people with different eye sizes?

I'm also wondering what and how can we alter the sampling rate of eye-tracking. The examples provided seem to be using Unity `Update()`, so are we supposed to change the `Fixed TimeStep` setting of Unity to make it, let's say, 90Hz?

Thanks in advance!

---

<div class="post-metadata">

### Author: ![kbabilinski](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/kbabilinski/32/19_2.png) [@kbabilinski](https://forum.magicleap.cloud/u/kbabilinski)
#### Post date: [November 15, 2023, 11:01pm UTC](https://forum.magicleap.cloud/t/eye-tracking-unity-api/2863/4 "2023-11-15T23:01:45Z")

</div>

Yes, you are correct currently we only track the portion of the eye open. A value of 0 would indicate that they eye is closed. Regarding the sampling rate, We currently provide eye tracking information at 60hz which is the same as the target frame rate of Unity Applications.

---

<div class="post-metadata">

### Author: ![zhhqu0305](https://avatars.discourse-cdn.com/v4/letter/z/a9a28c/32.png) [@zhhqu0305](https://forum.magicleap.cloud/u/zhhqu0305)
#### Post date: [November 16, 2023, 1:35am UTC](https://forum.magicleap.cloud/t/eye-tracking-unity-api/2863/5 "2023-11-16T01:35:38Z")

</div>

So you are saying that this `OpenAmount` isn't really related with the pupil size? I'm confused about how this could be, since you already had such feature in Magic Leap 1. If not, when is this feature planned to be released?

On the other hand, is there a way to access the claimed 90Hz data? This is what I found, in [Eye Tracking | MagicLeap Developer Documentation](https://developer-docs.magicleap.cloud/docs/guides/features/eye-tracking/).

> Eye tracking on Magic Leap 2 lets developers design natural and intuitive input and interaction scenarios. The Eye Tracking API provides information about what the user is looking at as a single eye-gaze ray (gaze origin and direction) at approximately 90 FPS (90 Hz). For eye tracking to work accurately, each user is required to go through an eye tracking user calibration.

If not, 60Hz data might also work in my case, but I'm still not sure if accessing data in the `Update()` method indicates that the sample interval will not be a constant. The app I'm developing needs to use the ML Camera to capture an image every 1.5 second, which seems to be causing delays in the app. I tried to put it in a background thread but the problem remains. I do want the data to be sampled at a constant interval. Please advise.

Thanks!

---

<div class="post-metadata">

### Author: ![kbabilinski](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/kbabilinski/32/19_2.png) [@kbabilinski](https://forum.magicleap.cloud/u/kbabilinski)
#### Post date: [November 16, 2023, 12:34pm UTC](https://forum.magicleap.cloud/t/eye-tracking-unity-api/2863/6 "2023-11-16T12:34:19Z")

</div>

You are correct, the eye open amount is not related to the pupil size. Unfortunately we are not able to share a timeline for this feature at this time. But I will forward your request to our voice of customer team.

Regarding the Update interval. You can obtain the data in fixed update, however you may need to change the **Update** setting inside the **Unity Input System Settings**. [Input settings | Input System | 1.1.1](https://docs.unity3d.com/Packages/com.unity.inputsystem@1.1/manual/Settings.html)

---

<div class="post-metadata">

### Author: ![zhhqu0305](https://avatars.discourse-cdn.com/v4/letter/z/a9a28c/32.png) [@zhhqu0305](https://forum.magicleap.cloud/u/zhhqu0305)
#### Post date: [November 16, 2023, 3:04pm UTC](https://forum.magicleap.cloud/t/eye-tracking-unity-api/2863/7 "2023-11-16T15:04:07Z")

</div>

Thanks for your reply. In that case, may I ask whether `MLEyes.LeftEye.PupilSize` on Magic Leap 1 is referring to the pupil size? I was looking at [this webpage](https://developer-documentation.magicleap.com/public/v0.26.0/UnityAPI/class_unity_engine_1_1_x_r_1_1_magic_leap_1_1_m_l_eyes_1_1_m_l_eye.html#details) but seems that there's no detailed description. I can find some relevant output when I search for "pupil" (see figure below), but it clearly links to the wrong place.

 ![image](https://us1.discourse-cdn.com/flex019/uploads/magicleap1/original/2X/b/b79f4b25f77e6d09a3763302d41aa03ead760ff2.png)  
Would you recommend switching to ML1 for pupil size readings?

Thanks!

---

<div class="post-metadata">

### Author: ![kbabilinski](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/kbabilinski/32/19_2.png) [@kbabilinski](https://forum.magicleap.cloud/u/kbabilinski)
#### Post date: [November 16, 2023, 10:32pm UTC](https://forum.magicleap.cloud/t/eye-tracking-unity-api/2863/8 "2023-11-16T22:32:27Z")

</div>

I would not recommend switching to ML1 since the device is about to reach it's end of life date. I'm not familiar with the Magic Leap 1 but it looks like it was able to read the pupil diameter.

---

<div class="post-metadata">

### Author: ![julien.villiger](https://avatars.discourse-cdn.com/v4/letter/j/50afbb/32.png) [@julien.villiger](https://forum.magicleap.cloud/u/julien.villiger)
#### Post date: [January 17, 2024, 8:28am UTC](https://forum.magicleap.cloud/t/eye-tracking-unity-api/2863/9 "2024-01-17T08:28:26Z")

</div>

> [@kbabilinski](#):
>
> can obtain

Hi,

I would like to know if there is any progress on the feature to read the pupil size? As far as I understand, this information was part of the Magic Leap One API. However, I have just discovered the following entry in the permissions in Unity: com.magicleap.permission.PUPIL\_SIZE. What does this permission allow me to do?

Thanks for further information.

---

<div class="post-metadata">

### Author: ![etucker](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/etucker/32/842_2.png) [@etucker](https://forum.magicleap.cloud/u/etucker)
#### Post date: [January 17, 2024, 4:23pm UTC](https://forum.magicleap.cloud/t/eye-tracking-unity-api/2863/10 "2024-01-17T16:23:37Z")

</div>

Hi @julien.villiger,

The pupil size is not available at the current moment. However, be on the lookout for future updates as this is something that we are currently working on.

Best,

El

---

<div class="post-metadata">

### Author: ![yanghouze](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/yanghouze/32/1470_2.png) [@yanghouze](https://forum.magicleap.cloud/u/yanghouze)
#### Post date: [February 2, 2024, 6:35am UTC](https://forum.magicleap.cloud/t/eye-tracking-unity-api/2863/11 "2024-02-02T06:35:35Z")

</div>

Hi, I noticed that in the Release blog, the zero iteration lab support pupil diameters and IPD. Is that something similar to App simulation? Also, currently, we still can't directly access these data in unity with MLSDK right?

---

<div class="post-metadata">

### Author: ![etucker](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/etucker/32/842_2.png) [@etucker](https://forum.magicleap.cloud/u/etucker)
#### Post date: [February 2, 2024, 9:18pm UTC](https://forum.magicleap.cloud/t/eye-tracking-unity-api/2863/12 "2024-02-02T21:18:02Z")

</div>

Hi @yanghouze,

Could you point me to the specific release blog that you are referring to?

Yes, this data is not accessible at the moment, but we are working on bringing access to this data in the future.

Best,

El

---

<div class="post-metadata">

### Author: ![yanghouze](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/yanghouze/32/1470_2.png) [@yanghouze](https://forum.magicleap.cloud/u/yanghouze)
#### Post date: [February 2, 2024, 9:38pm UTC](https://forum.magicleap.cloud/t/eye-tracking-unity-api/2863/13 "2024-02-02T21:38:55Z")

</div>

Hi,

> **[3.1.0 Zero Iteration (ZI) Lab Module | MagicLeap Developer Documentation](https://developer-docs.magicleap.cloud/docs/releases/release-2022-may/zero-iteration-release-notes/#zi-api-support)**
>
> Version 3.1.0

This link in section Miscellaneous[​](https://developer-docs.magicleap.cloud/docs/releases/release-2022-may/zero-iteration-release-notes/#miscellaneous-1)

---

<div class="post-metadata">

### Author: ![etucker](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/etucker/32/842_2.png) [@etucker](https://forum.magicleap.cloud/u/etucker)
#### Post date: [February 2, 2024, 9:49pm UTC](https://forum.magicleap.cloud/t/eye-tracking-unity-api/2863/14 "2024-02-02T21:49:11Z")

</div>

Yes, this is referring to the zero iteration module that let's you test your program before building it to the ML2. The eye pupil size will not be able to be accessed from here just yet, though.
