示例#1
0
        private void OnEnterState(State newState, State oldState)
        {
            switch (newState)
            {
            case State.Idle:
                m_GrabbedVisorRegion = VisorRegion.None;
                break;

            case State.Hovering:
                m_GrabbedVisorRegion = VisorRegion.None;
                break;

            case State.Grabbed:
                m_GrabbedVisorRegion = m_CurrentVisorRegion;
                if (oldState == State.Hovering)
                {
                    onPress?.Invoke(m_CurrentVisorRegion);
                }
                break;

            case State.Dragging:
                break;

            default:
                break;
            }
        }
示例#2
0
        public void HoverWaitForDrag()
        {
            if (!App.Instance.IsInStateThatAllowsAnyGrabbing())
            {
                SetDesiredState(State.Idle, InputManager.ControllerName.None, VisorRegion.None);
                return;
            }

            if (IsInRange(m_InteractingController))
            {
                VisorRegion visorRegion = GetVisorRegion(m_InteractingController);
                if (InputManager.Controllers[(int)m_InteractingController].GetCommandDown(InputManager.SketchCommands.Activate))
                {
                    SetDesiredState(State.Grabbed, m_InteractingController, visorRegion);
                }
                else
                {
                    SetDesiredState(State.Hovering, m_InteractingController, visorRegion);
                }
            }
            else
            {
                SetDesiredState(State.Idle, InputManager.ControllerName.None, VisorRegion.None);
            }
        }
示例#3
0
        public void SetDesiredState(State desiredState, InputManager.ControllerName controllerName, VisorRegion visorRegion)
        {
            if (desiredState == m_CurrentState && m_firstStateSet)
            {
                if (visorRegion != m_CurrentVisorRegion)
                {
                    onRegionExit?.Invoke(m_CurrentVisorRegion);
                    m_CurrentVisorRegion = visorRegion;
                    OnChangeVisorRegion();
                    onRegionEnter?.Invoke(m_CurrentVisorRegion);
                }
                return;
            }

            if (m_firstStateSet)
            {
                OnExitState(m_CurrentState, desiredState);
            }

            State oldstate = m_CurrentState;

            m_CurrentState          = desiredState;
            m_InteractingController = controllerName;
            m_firstStateSet         = true;

            bool switchRegion = visorRegion != m_CurrentVisorRegion;

            if (switchRegion)
            {
                onRegionExit?.Invoke(m_CurrentVisorRegion);
                m_CurrentVisorRegion = visorRegion;
            }

            OnEnterState(m_CurrentState, oldstate);

            if (switchRegion)
            {
                OnChangeVisorRegion();
                onRegionEnter?.Invoke(m_CurrentVisorRegion);
            }
        }
示例#4
0
        public void DragUpdate()
        {
            // only update drag region

            ControllerInfo interactingControllerInfo = InputManager.Controllers[(int)m_InteractingController];

            // release
            if (!interactingControllerInfo.GetCommand(InputManager.SketchCommands.Activate))
            {
                SetDesiredState(State.Idle, InputManager.ControllerName.None, VisorRegion.None);
                return;
            }

            // drag
            VisorRegion visorRegion = GetVisorRegion(m_InteractingController);

            if (visorRegion != m_CurrentVisorRegion)
            {
                SetDesiredState(State.Dragging, m_InteractingController, visorRegion);
            }
        }