示例#1
0
    // internal methods

    void ParseMessage(string aMessage)
    {
        GazeIO.Sample sample = JsonUtility.FromJson <GazeIO.Sample>(aMessage);
        if (sample.isValid)
        {
            //print($"WS:> sample = {sample.x}, {sample.y}");
            UpdateCursorLocation(sample);
            return;
        }

        GazeIO.State state = JsonUtility.FromJson <GazeIO.State>(aMessage);
        if (state.isValid)
        {
            //print($"WS:> status = {state.value}");
            UpdateState(state);
            return;
        }

        GazeIO.Device device = JsonUtility.FromJson <GazeIO.Device>(aMessage);
        if (device.isValid)
        {
            //print($"WS:> device name = {device.name}");
            UpdateDeviceInfo(device);
            return;
        }
    }
示例#2
0
    void UpdateState(GazeIO.State aState)
    {
        bool trackingChanged = aState.isTracking != _isTracking;

        _isTracking = aState.isTracking;

        // gaze ui and controls
        options.interactable        = !_isTracking && !aState.isBusy;
        calibrate.interactable      = !_isTracking && aState.isConnected && !aState.isBusy;
        toggleTracking.interactable = aState.isConnected && aState.isCalibrated && !aState.isBusy;
        toggleTracking.GetComponentInChildren <Text>().text = _isTracking ? "Stop" : "Start";
        gazeControls.SetActive(!_isTracking);

        State(this, new EventArgs());

        if (_isTracking && !_gameWasActvated)
        {
            ActivateGame();
        }

        if (trackingChanged)
        {
            // input module
            GetComponent <StandaloneInputModule>().enabled = !_isTracking;
            //GetComponent<GazeInput>().enabled = _isTracking;

            FirstPersonController fps = PlayerAvatar.getLocalPlayer()?.GetComponent <FirstPersonController>();
            if (fps != null)
            {
                fps.enabled = _isTracking;
            }

            if (_isTracking)
            {
                GameStart(this, new EventArgs());
            }
            else
            {
                GameStop(this, new EventArgs());
            }
        }
    }
示例#3
0
    void UpdateState(GazeIO.State aState)
    {
        bool trackingChanged = aState.isTracking != isTracking;

        isTracking = aState.isTracking;

        // gaze ui and controls
        options.interactable        = !isTracking && !aState.isBusy;
        calibrate.interactable      = !isTracking && aState.isConnected && !aState.isBusy;
        toggleTracking.interactable = aState.isConnected && aState.isCalibrated && !aState.isBusy && !isTracking;
        toggleTracking.GetComponentInChildren <Text>().text = isTracking ? "Stop" : "Start";
        //gazeControls.SetActive(!isTracking);

        State(this, new EventArgs());

        if (isTracking && !_trackingInitialized)
        {
            InitializeTracking();
            _log.ClearEvents();
        }

        if (trackingChanged)
        {
            // input module
            GetComponent <StandaloneInputModule>().enabled = !isTracking;

            if (isTracking)
            {
                Start(this, new EventArgs());
            }
            else
            {
                Stop(this, new EventArgs());
            }
        }
    }
示例#4
0
 public StateArgs(GazeIO.State aState)
 {
     state = aState;
 }