Step 1: Install and make sure your eye tracker is working

Version 4.0 of the Tobii Unity SDK for Desktop requires the following setup on your computer:

  • Unity 5 / 4.5 or higher (the Demo Scenes require Unity 5.3.7f1, the scripts work with Unity 5.0.0f4)
  • Windows 10, 8.1, or 7
  • Tobii Eye Tracking Core Software (either downloaded install bundle for peripheral eye tracker, or pre-installed on integrated systems)
  • Tobii consumer eye tracker peripheral or built-in device. You can find information about available products here: https://tobiigaming.com/products/.

The code samples in the SDK and the code snippets here in the documentation are all written in C#. It is also possible to write your scripts in UnityScript, if you prefer. Follow the instructions included with your eye tracker to download and install the correct Tobii Engine runtime software. Make sure the eye tracker and software is working correctly.

Step 2: Download the Tobii Unity SDK for Desktop

If you haven’t already done so, please create an account for these pages and download the Tobii Unity SDK for Desktop here:

Analytical Use

Tobii’s consumer eye trackers are primarily intended for personal interaction use and not for analytical purposes. Any application that stores or transfers eye tracking data must have a special license from Tobii.

Step 3: Import the SDK assets to a new Unity project

Save the Tobii Unity SDK for Desktop unitypackage file in an easy to remember place on disk. This unitypackage includes all the Tobii Unity SDK assets and demo scenes.

Open Unity, and create a New Unity Project. Select Windows as Target Platform. In the Unity Editor menu, select: Edit → Build Settings....

Select the following settings:

  • Platform: PC, Mac & Linux Standalone
  • Platform Target: Windows
  • Architecture: x86 or x86_64

 

Then, import all assets from the Tobii Unity SDK for Desktop unitypackage.

In the Unity Editor menu, select: Assets → Import Assets → Custom package...

  • Browse to the root folder of the Tobii Unity SDK for Desktop package you have downloaded and extracted to disk
  • Select the Tobii Unity SDK for Desktop unitypackage
  • Import all assets in the package

Step 4: Get to know the API and the eye-gaze data

Locate the Assets/Tobii folder in the Unity Editor Project panel. Expand it and find the DemoScenes folder. Open the 01_EyeTrackingData scene.

Add all the demo scenes to the build using Tools → Add Tobii SDK Demo Scenes to Build menu.

Press the play button and use the scenes’ next button to go through the provided demo scenes and get an overview of the core features of the SDK and popular eye tracking features in games. See also API Overview.

Step 5: Implement eye tracking features

To start using the TobiiAPI, add using Tobii.Gaming; to a script, type “TobiiAPI.” and browse the static functions of the API:

You might also want to explore the possibilities of the the built-in object selection using eye-gaze by adding the Gaze Aware component to some of your game objects. The following sections give some hints what to explore.

 

Drag and drop eye tracking features to your game

You get the latest Gaze Point by calling TobiiAPI.GetGazePoint() from any script where you have added using Tobii.Gaming; at the top of the script.

In the Tobii Gaming Team, we have implemented and helped implement eye tracking features in a number of games (from AAA titles to indie games) using this basic Gaze Point data. Over the years we have made a number of iterations and improvements to the algorithms. And now, for your convenience, we are making all our best algorithms freely available for you to use in your game (as long as they are used with Tobii eye trackers). Just drag, drop, and setup/adapt to fit your game. This is probably the fastest way you can add Tobii Eye Tracking features to your game.

Here is a list of features up for grab, and their scripts are all available in the DemoScenes folder of the SDK:

  • Extended View rotates the camera when you look towards the edges of the screen
  • Clean UI makes UI elements semi-transparent if you don’t look at them
  • Aim at Gaze aims your gun at the gaze point when you press an aim button
  • Interact at Gaze lets you interact directly with what you are looking at
  • Map Navigation pans to or zooms where you are looking at the press of a button
  • Dynamic Light Adaptation adjusts scene light exposure depending on your gaze point

Make game objects Gaze Aware

The SDK also comes with basic built-in gaze to object mapping. This enables eye tracking features like:

  • Interact at Gaze with the press of a button – interact directly with the object you are looking at
  • Gaze Awareness lets your game react to the user’s intentions by following their eye-gaze and attention

You can make a game object Gaze Aware by adding the Gaze Aware component in the Inspector: Add Component → Eye Tracking → Gaze Aware.

 

The component’s HasGazeFocus property lets the object know if the user’s eye-gaze is focused on the object or not. Read the HasGazeFocus property in the Update loop of a Gaze Aware game object and have it react to the user’s eye-gaze by changing its behavior or appearance. Or, let your underlying game algorithms query which game object the user is looking at using TobiiAPI.GetFocusedObject(), and have the game respond to the user’s eye-gaze in some other way.

// Example script on Gaze Aware object:
// Make object spin when looked at!

using Tobii.Gaming;
using UnityEngine;
 
[RequireComponent(typeof(GazeAware))]
public class SpinOnGaze : MonoBehaviour
{
    private GazeAware _gazeAware;
 
    void Start()
    {
        _gazeAware = GetComponent<GazeAware>();
    }
 
    void Update()
    {
        if (_gazeAware.HasGazeFocus)
        {
            transform.Rotate(Vector3.forward);
        }
    }
}

Note that Gaze Aware objects might not be a good fit for your particular game genre, game mechanics, or size and amount of game objects. But it is usually at least a very convenient way of prototyping object interaction ideas.

Configure Gaze Focus layers for Gaze Aware objects

If you use the Gaze Aware component, you should set up the Gaze Focus detection layers. By default, the first time you press ‘Play’ in a game that uses some Tobii Unity SDK feature, default settings for Gaze Focus are created. The default settings selects all existing layers to be tested for Gaze Aware objects. If a new layer is added to the game at a later point, and you want it to be tested for Gaze Aware objects, the layer has to be manually checked in the Gaze Focus layers dropdown menu. (Note that UI elements like buttons and labels do not work with the Gaze Aware component since the feature only works with objects with a UnityEngine.Collider).

Open the Eye Tracking Settings window from the Edit menu: Edit → Eye Tracking Settings...

 

Click to open the Gaze Focus Layers multi-selection dropdown and make sure that all the layers are selected where you want Gaze Aware game objects to be focusable using eye-gaze. Also make sure that layers you do not want to track with eye-gaze are not selected (like transparent layers).

Step 6: Build for standalone

The Tobii Unity SDK assets include an editor script for copying the correct plugin dll’s to the build output folder. The Tobii Unity SDK features are currently only available and working for PC (Windows 10/8.1/7), but the framework compiles on Mac and Linux as well (without copying the dll’s).

Done. Now let’s take a minute to review the API and some basic concepts of eye tracking.