Home › Forums › XR Discussions › Eye tracking data collection. › Reply To: Eye tracking data collection.
01/07/2022 at 11:25 #22162
Grant [Tobii]
Keymaster
Hi @haramchoi, you could use code along the following lines to get dwell time:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Tobii.G2OM;
public class HighlightAtGaze : MonoBehaviour , IGazeFocusable
{
private float _totalGazeTime;
private bool _hasFocus;
public void GazeFocusChanged(bool hasFocus)
{
_hasFocus = hasFocus;
if (!hasFocus)
{
Debug.LogWarning($"{gameObject.name} : {_totalGazeTime}");
}
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (_hasFocus)
{
_totalGazeTime += Time.deltaTime;
}
}
}
Let me know how it goes. Best Wishes.