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's Learn & Support section of the Tobii 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 API.
In SDK version 1.9 the VR support was deprecated.
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: \Assets\TobiiPro\VR\Prefabs
The screen based prefabs are located in: \Assets\TobiiPro\ScreenBased\Prefabs
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 .NET binding is compatible with Unity's version of C#. For more information check the .NET 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 Tobii Pro SDK API in Unity:
Start with the EyeTrackingOperations
, a static class residing in Tobii.Research
namespace.
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 Awake()
or 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 FindAllEyeTrackers
and GetEyeTracker
are instances of the class IEyeTracker
.
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).
The 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 GazeDataEventArgs
or HMDGazeDataEventArgs
.
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, OnDisable()
or OnApplicationQuit()
.
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 OnApplicationQuit()
, OnDestroy()
or similar).