コード例 #1
0
        /// <summary>
        /// Make sure the query target is set up before highlighting it.
        /// </summary>
        private void HighlightTarget()
        {
            if (CurrentTarget == null)
            {
                ProceedToNextTarget();
            }

            CurrentTarget.SetActive(true);
            HighlightTarget(highlightColor);
        }
コード例 #2
0
        /// <summary>
        /// Proceed to the next target. If the end is reached, fire an event that the target group has been fully
        /// iterated and restart the scene.
        /// </summary>
        private void ProceedToNextTarget()
        {
            Debug.Log("[TargetGroupIterator] >> Next target: " + currTargetIndex + " / " + nrOfTargetsToSelect);

            ResetAmountOfTries();
            Fire_OnTargetSelected();

            if (currTargetIndex < nrOfTargetsToSelect - 1)
            {
                // 1. Let's reset the highlight for the last target.
                HideHighlights();

                // 2. If "DisableDistractors" is true then let's hide the selected target
                if (DeactiveDistractors)
                {
                    CurrentTarget.SetActive(false);
                }

                // 3. Let's update to highlight the new target.
                currTargetIndex++;
                ShowHighlights();
            }
            else // At the end
            {
                // Fire an event to inform listeners that all targets have been iterated through.
                Fire_OnAllTargetsSelected();

                // Play some audio feedback (e.g., a cheerful applause).
                AudioFeedbackPlayer.Instance.PlaySound(AudioApplauseOnFinish);

                // If a scene is given, reload the scene after a short timeout.
                if (SceneToLoadOnFinish != "")
                {
                    StartCoroutine(EyeTrackingDemoUtils.LoadNewScene(SceneToLoadOnFinish, 0.1f));
                }
            }
        }
コード例 #3
0
    /// <summary>
    /// Finds the reticle closest to the center of the screen
    /// </summary>
    /// <returns>The reticle whose average anchors are closest to (0.5, 0.5)</returns>
    public void GetClosestTarget()
    {
        Target result          = CurrentTarget;
        float  closestDistance = float.MaxValue;

        foreach (Target t in Targets)
        {
            float distance = Vector3.Angle(transform.forward, t.transform.position - transform.position);
            if (t != CurrentTarget && distance < closestDistance)
            {
                result          = t;
                closestDistance = distance;
            }
        }
        if (CurrentTarget != null && CurrentTarget != result)
        {
            CurrentTarget.SetActive(false);
        }
        if (result != null && result != CurrentTarget)
        {
            result.SetActive(true);
        }
        CurrentTarget = result;
    }