With this SDK you will be able to easily find and get data from your Tobii eye tracker. If you are new to eye tracking we recommend that you spend some time exploring the content in Tobii Pro's Learn & Support section of the Tobii Pro website . There you will find a lot of information about how eye tracking works in general and how to design studies.
In the Common concepts section of this website, you will find information about concepts which are common for all supported languages, such as the different coordinate systems used, and how time stamps are defined.
There are two ways in which you can use the Tobii Pro SDK to develop applications in Unity: Either you use the prefabs included in the package (there are a number of them for both screen based eye trackers as well as for VR eye trackers). Or, you develop your own behaviours by going directly towards the Pro SDK Mono API.
Visit our download site for Tobii Pro SDK , and download the latest version of the Tobii Pro SDK Unity Binding.
The Tobii Pro SDK prefabs are meant as a help to start working with the Tobii Pro eye trackers within Unity. The source code used in the prefabs are included and can be used as a starting point for any eye tracking enabled project. Note that they are not guaranteed to be suited for any particular purpose and additional development and testing may be necessary for any given project or use case.
There are two groups of prefabs where each group covers the same use cases for screen based and VR eye trackers respectively:
The VR prefabs are located in:
The screen based prefabs are located in:
The [EyeTracker] or [VREyeTracker] prefabs are necessary for any of the other prefabs to work, but apart from that they are independent of each other.
[EyeTracker]/[VREyeTracker]prefab and dropping it into your Hierarchy Window.
[EyeTracker]/[VREyeTracker]object and use the Inspector Window to edit it's configuration.
There are two demo scenes located in
One for VR and one for screen based eye trackers.
They both highlight how to use the eye tracking prefabs in a simple scene.
You can try these out as demos, or use them as examples on how to use the Pro SDK Unity Prefabs.
The Tobii Pro SDK Mono API is an adaptation of the .NET binding that is compatible with Unity's version of C# (.NET 3.5 / Mono). Hence you can use the same syntax when using the Unity binding as you would when using the .NET binding (with some exceptions). However, since there are some important differences between the two bindings (regarding usage and supported methods), the Mono API has it's own reference guide pages.
Most eye tracking applications follow the same pattern in terms of in which order functionality is used. The order is usually as follows:
Here's how to do this with the Pro SDK Mono API in Unity:
Start with the
EyeTrackingOperations, a static class residing in
Use either the
FindAllEyeTrackers function to get a list of available eye trackers or the
GetEyeTracker function that only returns one eye tracker specified by the eye tracker URI.
This could be done in one of Unity's "initialization" event functions, such as
Start (convenient if you only have one eye tracker),
or on demand (if you want the user to be able to chose eye tracker).
The objects returned from the functions
GetEyeTracker are instances of the class
Through those objects you can interact with the eye trackers.
To calibrate the eye tracker, use either a
ScreenBasedCalibration or a
HMDBasedCalibration object (depending on the type of eye tracker).
ScreenBasedCalibration / HMDBasedCalibration class requires an
IEyeTracker object in the constructor.
More information about how a calibration works can be found in the section Calibration.
When you have the
IEyeTracker object and want to subscribe to gaze data, subscribe to either the
GazeDataReceived or the
HMDGazeDataReceived event (depending on the type of eye tracker).
The data will be available as
Note: The events in the SDK are called on a thread internal to the SDK. That thread can not safely set values that are to be read on Unity's main thread. The simplest way to make it safe is to enqueue the data, and dequeue it on the main thread, e.g. via
Update() in a MonoBehaviour.
This pattern is used in the examples included in the unitypackage.
In Unity it is important to unsubscribe from any Pro SDK data that you have unsubscribed to, otherwise Tobii Pro SDK will not be able to terminate properly, and you risk that your application/game will hang on exit.
Unsubscribe to the Tobii Pro SDK events together with your other clean up code, for example in one of Unity's terminating event functions,
To be on the safe side, you can also call the
Terminate() method on
EyeTrackingOperations to ensure that all Tobii Pro SDK resources gets cleaned.
Only do this when closing down application or object (i.e. in
OnDestroy() or similar).