Home Forums Software Development In game calibration with Unity? Reply To: In game calibration with Unity?

Robert [Tobii]

Here is a solution that works on my machine (Windows 8.1).

When the eye tracker goes into calibration mode, there is a property called EyeXHost.EyeTrackingDeviceStatus which you can monitor. It will change to EyeXDeviceStatus.Pending when the calibration starts and EyeXDeviceStatus.Tracking when the calibration is finished.

So right before the call to EyeXHost.LaunchRecalibration(), I set Application.runInBackground to true and then started to monitor the EyeTrackingDeviceStatus value. When it had changed to Pending and back to Tracking, I could use the Win32 function ShowWindowAsync to put the full-screen game in focus again.

    public const int SW_SHOWDEFAULT = 10;

    [DllImport("user32.dll", SetLastError = true)]
    public static extern bool ShowWindowAsync(IntPtr windowHandle, int nCmdShow);

    public static void ShowCurrentWindow()
        IntPtr hwnd = FindWindowWithThreadProcessId(Process.GetCurrentProcess().Id);
        Win32Helpers.ShowWindowAsync(hwnd, Win32Helpers.SW_SHOWDEFAULT);

Note that FindWindowWithThreadProcessId is implemented in the ScreenHelpers class.

Please let us know if the solution works for you. We will polish it and add it to the calibration example in the next release of the EyeX SDK for Unity.