Home Forums Game Integration Drawing game with Tobii eye tracker 5


Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #21837
    Zachary Gray

    Hello all, I am new to Unity and using C#. I have made a drawing game where you can draw a line by pressing down the mouse button but I intend this to be created with the eye; where the eye tracker will see where I am looking and it will generate the line on the screen instead of using the mouse. I am aware that the line might be jittery and inaccurate, but that doesn’t matter!

    There is a game object within my scene with a script (called LineGenerator) attached as a component, here is the piece of code that is attached:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class LineGenerator : MonoBehaviour
    public GameObject linePrefab;

    Line activeLine;

    // Update is called once per frame
    void Update()
    if (Input.GetMouseButtonDown(0))
    GameObject newLine = Instantiate(linePrefab);
    activeLine = newLine.GetComponent<Line>();

    if (Input.GetMouseButtonUp(0))
    activeLine = null;

    if (activeLine != null)
    Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

    The “linePrefab” stored in the public variable “GameObject” is a game object (stored in my prefab folder) with a line renderer attached.

    I have the Unity SDK downloaded and this might have the capability to do what I’d like it to, but I am fairly unfamiliar with that as well. Help would be tremendously appreciated!

    Grant [Tobii]

    Hi @zakg, the Tobii XR SDK comes with several sample scenes that should demonstrate clearly how to access the gaze streams .. please check them out and let us know how you get on. Best Wishes.

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