Exemplo n.º 1
0
        public bool Equals(FocusedObject that)
        {
            if (this.IsValid && that.IsValid &&
                this.GameObject.GetInstanceID() == that.GameObject.GetInstanceID())
            {
                return(true);
            }

            if (!this.IsValid && !that.IsValid)
            {
                return(true);
            }

            return(false);
        }
        /// <summary>
        /// Updates the gaze focus according to the latest gaze data.
        /// </summary>
        public void UpdateGazeFocus()
        {
            if (!IsInitialized)
            {
                return;
            }

            IEnumerable <GazePoint> lastGazePoints;

            if (!TryGetLastGazePoints(out lastGazePoints))
            {
                FocusedObject = Scorer.GetFocusedObject();
                return;
            }

            FocusedObject = Scorer.GetFocusedObject(lastGazePoints, Camera);
        }
        /// <summary>
        /// Unregisters the supplied <see cref="IGazeFocusable"/> component so
        /// that the <see cref="GameObject"/> it belongs to no longer can be
        /// focused using eye-gaze.
        /// </summary>
        /// <param name="gazeFocusableComponent"></param>
        public void UnregisterFocusableComponent(IGazeFocusable gazeFocusableComponent)
        {
            var instanceId = gazeFocusableComponent.gameObject.GetInstanceID();

            if (_focusedObject.IsValid &&
                _focusedObject.GameObject.GetInstanceID() == instanceId)
            {
                FocusedObject = FocusedObject.Invalid;
            }

            FocusableObjects.Remove(instanceId);

            if (Scorer != null)
            {
                Scorer.RemoveObject(gazeFocusableComponent.gameObject);
            }
            if (_multiScorer != null)
            {
                _multiScorer.RemoveObject(gazeFocusableComponent.gameObject);
            }
        }