Tobii EyeX Controller is an awesome product who give you the power with… your eyes ! I’m not joking, you can control things with your eyes and it works pretty well :) The firm who  product this controller also made a SDK for Unity so let’s play with him !Tobii_Device

How it works ?

With several sensors, the controller is able to track your eyes position to know where you are looking at. You just need to put the device at the bottom of your screen and to calibrate it! Ready to rock ?

Example

Create a new project in Unity  (any recent version will work).

Download the SDK

You can find the SDK here : http://developer.tobii.com/downloads/

unity_download_sdk

 Install the package

Unzip the downloaded file and double click on EyeXFramework.unityPackage. This will open a popup to import the package in your Unity project.

Interactive sphere

Select GameObject > Create Other > Sphere.

On that sphere, we will add 3 components :

  • Gaze Aware (from Tobii SDK)
  • Particle system
  • Custom script to show particles only when you look at the sphere

Gaze Aware

Select the sphere and in the Inspector panel, select Add component > Tobii EyeX > Gaze Aware. This script sets the sphere as reactive to the sensor, we can now know when the player focus the sphere.

Particle system

Select the sphere and in the Inspector panel, select Add component > Effects >Particle System. Set the property Start Lifetime to 1 and disable the property Emission.

Custom script

Once again, select the sphere and in the Inspector panel, select Add component > New script > Csharp > Create and Add. Open the script and copy this code snippet inside :

using UnityEngine;
using System.Collections;

public class ParticleBehavior : MonoBehaviour
{
	private ParticleSystem _particleComponent;
	private GazeAwareComponent _gazeAwareComponent;

	// Use this for initialization
	void Start ()
	{
		_particleComponent = GetComponent<ParticleSystem>();
		_gazeAwareComponent = GetComponent<GazeAwareComponent>();
	}

	// Update is called once per frame
	void Update ()
	{
		if (_gazeAwareComponent.HasGaze)
		{
			_particleComponent.enableEmission = true;
		}
		else
		{
			_particleComponent.enableEmission = false;
		}
	}
}

We use the property HasGaze() of GazeAwareComponent to determinate whether the sphere is focus or not. The property enableEmission of the class ParticleSystem is use to active the particle system.

unity_particles_playing

 

Have fun !