Home Forums Unity SDK Can I get gaze position in full screen coordinates?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #18199
    Trejkaz
    Participant

    Hi.

    I would like my tracking to keep working regardless of the size of the game window. But when the window is smaller than the entire screen, which is always the case when running from the editor (but also particularly also when the editor or game is minimised!), I start getting readings for the gaze point which don’t reflect where I’m looking.

    So is there a way to get this data in the coordinates of the entire screen instead of relative to the game window? There’s nothing on GazePoint itself, but I thought maybe there would be some configuration _somewhere_ allowing this.

    The use case here is I want to move my character’s eyes to reflect what they’re looking at, which is usually a game window that isn’t the current Unity application.

    The workaround of always having my Unity game window maximised is something I’d like to try and avoid.

    #18200
    Grant [Tobii]
    Keymaster

    Hi @trejkaz, thanks for your query. Could you kindly let us know exactly which Tobii eye trackers you are using together with the precise SDK (we have several Unity Varieties) and a summary of system specifications. Thereafter, we will be better placed to deal with the issue. Best Wishes.

    #18201
    Trejkaz
    Participant

    Tracker: Tobii 4C
    SDK: Tobii Unity SDK for Desktop v3.0 (beta)

    Other than that, Unity version is 2018.4.20f1 running on Windows 10, but I’m not pinned to a specific version of Unity for this project.

    #18206
    Trejkaz
    Participant

    _(repeating this as the reply appears to have disappeared)_

    Digging around the internals a bit, I found a solution, albeit a bit of a dirty one.

    First, in ScreenHelpers.cs, I added a new GameViewBoundsProvider:

      internal class FullScreenGameViewBoundsProvider : GameViewBoundsProvider
      {
        public override Rect GetGameViewClientAreaNormalizedBounds()
        {
          return new Rect(0, 0, 1, 1);
        }
      }

    Then in TobiiHost.Awake(), I commented out the code initialising _gameViewBoundsProvider and replaced it with my own:

        void Awake()
        {
          // Stubbed the game view bounds provider to get full screen always.
          _gameViewBoundsProvider = new FullScreenGameViewBoundsProvider();

          // …

    This _appears_ to work. I can minimise the editor window, switch to OBS and see the output of the capture from Unity, and it appears to behave the same as if the game window was full screen. The only bad thing about it is that it did require modifying the internal code.

    I did find another way, which is to get the GameViewInfo and try to calculate it from that, but the values I was getting out of that didn’t seem like it was reflecting the true position of the window, and I figured that it is more elegant to just have the host think that the window is taking up the full screen at all times.

    #18218
    Grant [Tobii]
    Keymaster

    Hi @trejkaz, glad that you managed to find a workaround. You may also consider this less invasive approach.

    TobiiHost.cs

            private void TrackWindow()
            {
                if (_gameViewBoundsProvider.Hwnd != IntPtr.Zero)
                {
    ---> Replace this line               //TobiiGameIntegrationApi.TrackWindow(_gameViewBoundsProvider.Hwnd);
    ---> With this code:
                    var trackers = TobiiGameIntegrationApi.GetTrackerInfos();
                    if (trackers.Any())
                    {
                        TobiiGameIntegrationApi.TrackTracker(trackers[0].Url);
                    }
    ---
                    IsInitialized = true;
                }
            }

    This will thereafter always provide fullscreen coordinates

    However, it will display incorrectly in the editor since remapping functions will work incorrectly
    as the default SDK works fine in the editor with default layout and 1:1 Scale (zoom)

    Something to bear in mind is that this code will always connect to the first tracker it finds in the system and may fail if using a VR tracker or two eye trackers.

    Hopefully, this information is of use! Best wishes.

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