Home Forums Software Development In game calibration with Unity?

Tagged: , ,

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
  • #2128
    Titouan Millet


    We recently made a game with Unity using the Tobii Eyex as a unique controller. It’s called Grab Your Eyes, and is kind of a serie of quick minigames asking the player to use their glance in different ways, in a crazy insane TV environment (I’ll create a dedicated topic later).

    The game works great once the eye tracker calibrated for the player, but since it is likely to be showcased in several events, I’m trying to integrate the calibration process directly in the game, so each new player passing by would be able to recalibrate the eye tracker for themselves without leaving the game, launching the Engine and restarting the game.

    I was surprised to discover that it’s not a feature already integrated in the SDK for Unity. Is anybody already managed to integrate a calibration process in Unity? Or, are there any documentation with examples from which I could learn how to do it myself? I would like to keep it in C# since I know nothing about C/C++ and .NET, or maybe it’s not possible?

    Robert [Tobii]


    Cool to hear about the Grab your Eyes game. I found your trailer on YouTube and it looks crazy and fun.

    At the moment it is not possible to perform in-game calibration with the EyeX SDK for Unity. However, in the next EyeX Engine release that will be released in a couple of weeks, it will be possible to launch the calibration programmatically. I hope that it will be a good solution for you.

    Titouan Millet

    Oh yeah, it sounds like what I need!
    Thank you for the reply, I’ll wait for the next EyeX Engine release then.

    Robert [Tobii]

    Hi again,

    Today we released the EyeX Engine 1.1.0 and a matching EyeX SDK for Unity that contains an example that launches the calibration. Please check it out and let us know if it works for you.

    Titouan Millet

    Yes it works, thank you!

    However, if I run the build of the game fullscreen, the game screen disappears when the recalibration is complete. I mean, the recalibration screen closes itself, but instead of returning to the fullscreen game, it returns to the desktop. I can still hear the sound of the game, but there is no way to open the game window, that is still running in the background somehow but is invisible. Actually I can’t even do anything else then (the computer is like frozen, except for the taskbar) and have to quit the game from the task manager to return to a normal state. Basically I think it’s some kind of conflict between the two fullscreens (the recalibration and the game). It may also just be an issue with my computer.

    If I launch the game windowed, it still works after the recalibration (it doesn’t disappear and I can continue to play the game). It also work if I disable the fullscreen mode from a script before launching the recalibration. I would like to return in fullscreen after the recalibration though, is there a way to get when the recalibration process is finished? Some kind of closing event or callback?

    If not, I’ll just activate the fullscreen mode once the player start the game, I mean after the “menu” from which they can recalibrate the eye tracker.

    Robert [Tobii]

    Sorry for late reply. We have been discussing how to solve the full-screen issue, but there has been a lot of Christmas and New Year’s celebrations coming in between. We’ll let you know when we have a solution or workaround. If you or someone else find a viable workaround, please share it.

    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.

    Titouan Millet

    Sorry for the delay, and thank you again for your reply.

    Following your advice, I was able to monitor the change between Pending and Tracking, but I simply used Screen.fullScreen = false/true, since I can’t make your solution with ShowCurrentWindows work correctly on my laptop (it doesn’t re-focus on the game windows). But it’s not a big deal at all actually, the point was to automate the system without any problem nor asking the player for futher manipulation, and it works good now.

    I made a topic for the game the team and I are working on : http://developer.tobii.com/community/forums/topic/grab-your-eyes/

    David Hill

    About 2 years later i’m looking for that screenhelpers class to try out that solution. where can i find it? are there any news regarding get back to fullscreen in builds?

    thank you in advance


    Jenny [Tobii]

    Hi David (@hillda),

    There is still no obvious or direct way to do this programmatically, because the recalibration tool is run in its separate and standalone process. Though Robert’s suggestion to monitor state changes seems a bit fragile to me, it probably works reasonably well.

    In the Tobii EyeX SDK for Unity 1.7, you find the FindWindowWithThreadProcessId method in the WindowsHelpers class, found here: Assets/StandardAssets/EyeXFramework/WindowHelpers.cs

    In the recently released Tobii EyeTracking SDK for Unity – v2.0 (Beta), the LaunchRecalibration method is not included in the EyeTrackingHost API.

    What we usually do ourselves when we are out at shows demoing games with eye tracking to many people is to use a combination of guest calibration and Alt-Tab:
    1. When in the game, press Ctrl-Shift-F9 to launch a guest calibration
    2. When calibration is done, Alt-Tab back to the game (using Window’s built-in application switcher)
    This is feasible for us since we are always there to talk to and guide each user at the show.

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.