Beispiel #1
0
        private void UpdateUiVrMode()
        {
            if (!GazeManager.Instance.IsActivated)
            {
                // GazeManager not connected
                _QualityText.enabled = true;
                _InfoText.enabled    = true;
                _InfoText.text       = "Unable to connect to Server";
            }
            else
            {
                if (GazeManager.Instance.IsCalibrating)
                {
                    // Hide UI during calibration

                    if (GazeGUIController.ShowGazeIndicator)
                    {
                        _ToggleIndicatorState = true;
                        GazeGUIController.ToggleIndicatorMode();
                    }
                }
                else
                {
                    // Update main calibration info text
                    string calibrate;
                    if (!GazeManager.Instance.IsCalibrated)
                    {
                        calibrate = "Press <b>FIRE1*</b> or <b>SWIPE FORWARD</b>\nto begin calibration";
                    }
                    else
                    {
                        calibrate = "Press <b>FIRE1*</b> or <b>SWIPE FORWARD</b>\nto begin re-calibration\n\nPress <b>FIRE2</b> or <b>SWIPE DOWN</b> to start demo";
                    }
                    _InfoText.text    = calibrate;
                    _InfoText.enabled = true;

                    // Update Calibration quality
                    CalibrationResult result    = GazeManager.Instance.LastCalibrationResult;
                    string            calibText = UnityCalibUtils.GetCalibString(result);

                    if (null != result)
                    {
                        _QualityText.rectTransform.SetRendererEnabled(true);
                        _QualityText.text = "<b>Calibration Quality: </b>" + calibText;
                    }

                    //restore pre-calibration indicator state
                    if (_ToggleIndicatorState)
                    {
                        _ToggleIndicatorState = !_ToggleIndicatorState;
                        GazeGUIController.ToggleIndicatorMode();
                    }
                }
            }
        }
Beispiel #2
0
        public virtual List <Point2D> GetCalibrationPoints(int rows, int cols)
        {
            float  width       = _Camera.pixelWidth;
            float  height      = _Camera.pixelHeight;
            double calibWidth  = Math.Round(width * CalibAreaSizeRelativeX);
            double calibHeight = Math.Round(height * CalibAreaSizeRelativeY);
            double paddingHors = Math.Round((width - calibWidth) * .5f);
            double paddingVert = Math.Round((height - calibHeight) * .5f);

            return(UnityCalibUtils.InitCalibrationPoints(
                       rows,
                       cols,
                       width, height,
                       paddingHors, paddingVert));
        }
Beispiel #3
0
        private void UpdateUiRemoteMode()
        {
            if (!GazeManager.Instance.IsActivated)
            {
                // GazeManager not connected, optional re-connect to server

                if (!_ActionButton.gameObject.activeInHierarchy)
                {
                    _ActionButton.gameObject.SetActive(true);

                    _ActionButton.GetComponent <Button>().onClick.RemoveAllListeners();
                    _ActionButton.GetComponent <Button>().onClick.AddListener(() =>
                    {
                        GazeManager.Instance.ActivateAsync();
                    });
                    _ActionButton.GetComponentInChildren <Text>().text = "Reconnect to server";
                }
            }
            else
            {
                if (GazeManager.Instance.IsCalibrating)
                {
                    // Hide UI during calibration

                    if (GazeGUIController.ShowGazeIndicator)
                    {
                        _ToggleIndicatorState = true;
                        GazeGUIController.ToggleIndicatorMode();
                    }

                    _ActionButton.gameObject.SetActive(false);
                    _StartButton.gameObject.SetActive(false);
                }
                else
                {
                    // Update UI depending on state

                    if (!_ActionButton.gameObject.activeInHierarchy)
                    {
                        _ActionButton.gameObject.SetActive(true);

                        string calibrate;
                        if (!GazeManager.Instance.IsCalibrated)
                        {
                            calibrate = "Calibrate";
                        }
                        else
                        {
                            calibrate = "Re-calibrate";
                        }

                        _ActionButton.GetComponentInChildren <Text>().text = calibrate;

                        _ActionButton.GetComponent <Button>().onClick.RemoveAllListeners();
                        _ActionButton.GetComponent <Button>().onClick.AddListener(() =>
                        {
                            if (GazeManager.Instance.Trackerstate != GazeManager.TrackerState.TRACKER_CONNECTED)
                            {
                                _StateNotifyer.ShowState("Trackerstate is invalid!");
                            }
                            else
                            {
                                _CalibrationManager.StartCalibration();
                            }
                        });

                        if (_ToggleIndicatorState)
                        {
                            _ToggleIndicatorState = !_ToggleIndicatorState;
                            GazeGUIController.ToggleIndicatorMode();
                        }
                    }

                    if (!_StartButton.gameObject.activeInHierarchy)
                    {
                        if (GazeManager.Instance.Trackerstate == GazeManager.TrackerState.TRACKER_CONNECTED)
                        {
                            _StartButton.gameObject.SetActive(true);
                        }
                    }

                    if (!_QualityText.rectTransform.IsRendererEnabled())
                    {
                        CalibrationResult result = GazeManager.Instance.LastCalibrationResult;

                        string calibText = UnityCalibUtils.GetCalibString(result);
                        _QualityText.text = "<b>Calibration Quality: </b>" + calibText;

                        _QualityText.enabled = true;
                    }
                }
            }
        }