//-------------------------------------------------------------------- // MonoBehaviour event functions (messages) //-------------------------------------------------------------------- /// <summary> /// Initialize helper classes and state accessors on Awake /// </summary> void Awake() { _runInBackground = Application.runInBackground; #if UNITY_EDITOR _gameViewBoundsProvider = CreateEditorScreenHelper(); #else _gameViewBoundsProvider = new UnityPlayerGameViewBoundsProvider(); #endif _gazeFocus = new GazeFocus(); _screenBoundsStateAccessor = new StateAccessor <Tobii.EyeX.Client.Rect>(StatePaths.EyeTrackingScreenBounds); _displaySizeStateAccessor = new StateAccessor <Size2>(StatePaths.EyeTrackingDisplaySize); _eyeTrackingDeviceStatusStateAccessor = new StateAccessor <EyeTrackingDeviceStatus>(StatePaths.EyeTrackingState); _userPresenceStateAccessor = new StateAccessor <Tobii.EyeX.Framework.UserPresence>(StatePaths.UserPresence); _userProfileNameStateAccessor = new StateAccessor <string>(StatePaths.ProfileName); _userProfileNamesStateAccessor = new EnumerableStateAccessor <string>(StatePaths.EyeTrackingProfiles); _gazeTracking = new StateAccessor <Tobii.EyeX.Framework.GazeTracking>(StatePaths.GazeTracking); }
private void UpdateFocusConfidenceScore(IEnumerable <GameObject> objectsInGaze) { foreach (var objectInGaze in objectsInGaze) { var instanceId = objectInGaze.GetInstanceID(); if (!_scoredObjects.ContainsKey(instanceId)) { if (!GazeFocus.IsFocusableObject(objectInGaze)) { continue; } _scoredObjects.Add(objectInGaze.GetInstanceID(), new ScoredObject(objectInGaze, GainGazeDwellTime, LoseGazeDwellTime)); } ScoredObject hitObject = _scoredObjects[instanceId]; hitObject.AddHit(Time.time, Time.deltaTime); } ClearFocusedObjectIfOld(); }
public FocusedObject GetFocusedObject(IEnumerable <GazePoint> lastGazePoints, Camera camera) { var gazePoint = lastGazePoints.Last(); if (!gazePoint.IsWithinScreenBounds) { return(FocusedObject.Invalid); } GameObject focusedObject = null; RaycastHit hitInfo; if (HitTestFromPoint.FindObjectInWorld(out hitInfo, gazePoint.Screen, camera, MaximumDistance, LayerMask)) { if (GazeFocus.IsFocusableObject(hitInfo.collider.gameObject)) { focusedObject = hitInfo.collider.gameObject; } } return(new FocusedObject(focusedObject)); }
private static void NotifySettingsChanged() { GazeFocus.SettingsUpdated(); }