The Tobii Pro SDK enables you to easily find and get data from your Tobii eye tracker. If you are new to eye-tracking, you should explore the content in Tobii Pro's Learn & Support section of the Tobii Pro website . It tells you a lot about how eye-tracking works in general and how you design studies.
The Common concepts section of this website, explains common concepts for all supported languages, such as the different coordinate systems, and how time stamps are defined.
You can use the Tobii Pro SDK in two ways for developing Unity applications. Either you use the Pro SDK Prefabs included in the package (for both screen based eye trackers and VR eye trackers), or you develop your own behaviours using the Pro SDK Mono API.
Go to our download site for Tobii Pro SDK , and download the latest version of the Tobii Pro SDK Unity Binding.
The Tobii Pro SDK prefabs help you start working with the Tobii Pro eye trackers in Unity. The prefabs’ source code is included, and you can used it as a starting point for an eye-tracking-enabled project. However, there is no guarantee that they will suit a particular purpose; therefore, additional development and testing may be required for your project or use case.
There are two groups of prefabs, screen-based and VR, that cover the same use cases:
The VR prefabs are located in:
The screen based prefabs are located in:
The [EyeTracker] or [VREyeTracker] prefabs are required to get the other prefabs to work, but the rest 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.
Two demo scenes are located in
\Assets\TobiiPro\Examples\PrefabDemo, one for VR and one for screen based eye trackers.
Both highlight how you use the eye tracking prefabs in a simple scene.
Test them as demos or use them as examples on how to use 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 use the same syntax for the Unity binding as you would for the .NET binding with some exceptions. However, there are some differences between the two bindings regarding usage and supported methods, so check the Mono API’s 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 to get the sole eye tracker specified by the eye tracker URI.
Do it in one of Unity's "initialization" event functions, such as
Start (convenient if you only have one eye tracker),
or on demand (if the user is supposed to be able to select eye tracker).
The objects returned from the functions
GetEyeTracker are instances of the class
Use these objects to interact with the eye trackers.
Calibrate the eye tracker by using 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 calibrations is available in the section on 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 is 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. Fix that by enqueuing the data, and dequeuing 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 subscribed to, otherwise Tobii Pro SDK cannot 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 an application or object (i.e. in
OnDestroy() or similar).