Home › Forums › Software Development › Unity SDK – eyetracker IsConnected/Disconnected › Reply To: Unity SDK – eyetracker IsConnected/Disconnected
Hi Peter,
What you need is two levels of checks: 1) if there is an EyeX Engine running on the machine, and 2) if the eye tracker is up and running tracking the user’s eyes.
Here are some code snippets how to perform these checks.
1) There is a static property on the EyeXHost to check if the EyeXEngine is running:
EyeXHost.EyeXAvailability
Check if it is equal to EyeXEngineAvailability.Running
2) Here is what you need to add in a mono behavior class to (continously) check if the eye tracker is up and running and tracking the user’s eyes:
private EyeXHost _eyeXHost;
void Start()
{
_eyeXHost = EyeXHost.GetInstance();
}
void Update()
{
var eyeTrackerDeviceStatus = _eyexHost.EyeTrackingDeviceStatus;
if(eyeTrackerDeviceStatus == EyeXDeviceStatus.Tracking)
{
// use EyeX
}
else
{
// use mouse
}
}
I hope this gives you enough to adapt to do something appropriate for your game.