/// <summary>
    /// Update cursor position on canvas based on a ray originating at the VR headset's position and using the headset's forward direction.
    /// </summary>
    private void TrackHead()
    {
        Vector3 direction = VRCamera.transform.forward;
        Ray     ray       = new Ray(_rayOrigin, direction);

        CurrentHeadGazeScreenPoint = VRCamera.WorldToScreenPoint(_rayOrigin + ray.direction * POINT_CALCULATION_DISTANCE);
        HandleHeadRay(ray);
    }
    /// <summary>
    /// Update cursor position on screen based on the eye gaze ray from VRHMD (if using eyetracking as control method).
    /// This function is also called if RecordGazePosition is true, in which case the ray is still handled but the cursor position is not updated.
    /// This is in case we want to record gaze position regardless of using eyetracking as control method.
    /// </summary>
    private void TrackEyes()
    {
        List <Vector3> eyeDirections = new List <Vector3>();

        switch (TestController.Instance.TestBlockData.SelectedVRHMD)
        {
        case TestBlock.VRHMD.VIVE:
            Vector3 gaze = Pupil.values.GazePoint3D;
            //Transform and correct eye-tracking
            gaze = (transform.rotation * gaze).normalized;
            Vector3 delta = transform.forward.normalized - gaze;
            gaze = gaze + delta * 2;
            //float eyeConfidence = (Pupil.values.Confidences[0] + Pupil.values.Confidences[1]) / 2.0f;
            //if (eyeConfidence > 0.7f)
            //{
            eyeDirections.Add(gaze);
            //}
            break;

        case TestBlock.VRHMD.FOVE:
            FoveInterface.EyeRays rays = _foveInterface.GetGazeRays();
            EFVR_Eye eyeClosed         = FoveInterface.CheckEyesClosed();
            switch (eyeClosed)
            {
            case (EFVR_Eye.Neither):
                eyeDirections.Add(rays.left.direction);
                eyeDirections.Add(rays.right.direction);
                break;

            case (EFVR_Eye.Left):
                eyeDirections.Add(rays.right.direction);
                break;

            case (EFVR_Eye.Right):
                eyeDirections.Add(rays.left.direction);
                break;

            case (EFVR_Eye.Both):
                eyeDirections.Add(Vector3.zero);
                break;
            }
            break;
        }

        Vector3 direction = Vector3.zero;

        foreach (Vector3 eyeDirection in eyeDirections)
        {
            direction += eyeDirection;
        }
        direction = direction / eyeDirections.Count;
        Ray ray = new Ray(_rayOrigin, direction);

        ray = GetAverageEyeRay(ray);
        CurrentEyeGazeScreenPoint = VRCamera.WorldToScreenPoint(_rayOrigin + ray.direction * POINT_CALCULATION_DISTANCE);
        if (CurrentControlMethod == TestBlock.ControlMethod.Eyetracking)
        {
            HandleRay(ray);
        }
        else
        {
            HandleGazeTrackingRay(ray);
        }
        Debug.DrawRay(ray.origin, ray.direction * 100);
    }