Ejemplo n.º 1
0
    private void SetInteractionState(ref InteractionState interactionState, SteamVR_Action_Boolean_Source action)
    {
        // Pressed this frame

        // Released this frame

        // Is pressed
    }
        void Update()
        {
            if (m_strokeDevice == null)
            {
                SteamVR_Action_Boolean_Source drawStrokeAction = SteamVR_Actions._default.DrawStroke[SteamVR_Input_Sources.Any];

                if (drawStrokeAction.stateDown)
                {
                    if (drawStrokeAction.activeDevice == SteamVR_Input_Sources.Any)
                    {
                        m_strokeDevice = SteamVR_Input_Sources.RightHand;
                    }
                    else
                    {
                        m_strokeDevice = drawStrokeAction.activeDevice;
                    }

                    //Debug.Log($"DOWN: {m_strokeDevice.Value}");

                    PointerPoint pp = CreatePointerPoint();

                    m_inkWriter.OnPointerPressed(ref pp);
                }
            }
            else
            {
                SteamVR_Action_Boolean_Source action = SteamVR_Actions._default.DrawStroke[m_strokeDevice.Value];

                if (action.stateUp)
                {
                    //Debug.Log($"UP: {m_strokeDevice.Value}");

                    PointerPoint pp = CreatePointerPoint();

                    m_inkWriter.OnPointerReleased(ref pp);

                    m_strokeDevice = null;

                    if (m_pathProvider != null)
                    {
                        // copy the path
                        List <float> path = new List <float>(m_pathProvider.GetPath());
                        m_paths.Add(path);
                    }
                }
                else if (action.state)
                {
                    //Debug.Log($"MOVE: {m_strokeDevice.Value}");

                    PointerPoint pp = CreatePointerPoint();

                    m_inkWriter.OnPointerMoved(ref pp);
                }
            }
        }
    private void Update()
    {
        SteamVR_Action_Boolean_Source triggerState = SteamVR_Actions.default_GrabPinch[SteamVR_Input_Sources.LeftHand];

        if (triggerState.stateDown)
        {
            SetVisible(true);
        }
        else if (triggerState.stateUp)
        {
            SetVisible(false);
        }
    }
Ejemplo n.º 4
0
    private void Update()
    {
        if (!_magManager.IsMagnifying)
        {
            return;
        }

        // Set + adjust position once per frame
        SetMarkerPosition();
        // If marker still collides after adjustment, target cannot be teleported to
        bool isTargetValid = IsTeleportTargetValid();

        _dotImage.SetValid(isTargetValid);

        _log.Append("targetValid", isTargetValid);

        SteamVR_Action_Boolean_Source triggerDown = SteamVR_Actions.default_GrabPinch[SteamVR_Input_Sources.RightHand];

        if (triggerDown.stateDown && !_teleporter.IsTeleporting)
        {
            if (isTargetValid)
            {
                _isHoldingTrigger = true;
                _holdDownTime     = 0f;

                SetTeleportTarget();
                _teleportMarker.SetAlpha(1f, 1f);
            }
            else
            {
                _teleportCandidate = null;
                _teleportMarker.SetAlpha(0f, 0f);
                _log.CommitLine();
                return;
            }
        }
        if (triggerDown.stateUp)
        {
            _isHoldingTrigger  = false;
            _teleportCandidate = null;
            _teleportMarker.SetAlpha(0f, 0f);
        }

        if (_isHoldingTrigger)
        {
            _holdDownTime += Time.deltaTime;
            _dotImage.SetProgress(_holdDownTime / _activationTime);
            if (_holdDownTime >= _activationTime)
            {
                _isHoldingTrigger = false;
                _log.Append("isTeleporting", true);

                // Start teleport
                _teleporter.Teleport(_teleportCandidate.Value);
                OnGazeTeleport(_teleportCandidate.Value);
                _teleportCandidate = null;
            }
        }
        else
        {
            _teleportMarker.SetAlpha(0f, 0f);
            _dotImage.SetProgress(1f);
        }
        _log.CommitLine();
    }