示例#1
0
        protected void SetGUIWrapperState(GUIWrapperState state)
        {
            int clickCount = 0;

            if (state.mouseDownButton >= 0)
            {
                clickCount = Mathf.Max(1, state.clickCount);
            }

            m_GUIWrapper.mouseButton.Returns(state.mouseButton);
            m_GUIWrapper.clickCount.Returns(clickCount);
            m_GUIWrapper.isShiftDown.Returns(state.isShiftDown);
            m_GUIWrapper.isAltDown.Returns(state.isAltDown);
            m_GUIWrapper.isActionKeyDown.Returns(state.isActionKeyDown);
            m_GUIWrapper.IsMouseDown(state.mouseDownButton).Returns(true);
            m_GUIWrapper.IsMouseUp(state.mouseUpButton).Returns(true);

            if (state.keyDown != KeyCode.None)
            {
                m_GUIWrapper.IsKeyDown(state.keyDown).Returns(true);
            }

            m_HotControl = state.hotControl;
            m_GUIWrapper.IsMultiStepControlHot(state.multiStepHotControl).Returns(true);
            m_GUIWrapper.IsViewToolActive().Returns(x => state.viewToolActive);
        }
示例#2
0
        public bool DoCancelMultistepAction(bool force)
        {
            if (force)
            {
                m_GUIWrapper.SetMultiStepControlHot(0);
                return(true);
            }

            if ((!m_GUIWrapper.IsMultiStepControlHot(0) && (m_GUIWrapper.IsMouseDown(1) || m_GUIWrapper.IsKeyDown(KeyCode.Escape))))
            {
                m_GUIWrapper.SetMultiStepControlHot(0);
                m_GUIWrapper.UseCurrentEvent();
                return(true);
            }

            return(false);
        }
示例#3
0
        private bool IsActionTriggering(Transform boneTransform, BoneGizmoAction action)
        {
            if (!IsActionActive(boneTransform, action))
            {
                return(false);
            }

            if (action == BoneGizmoAction.Select)
            {
                return(m_GUIWapper.IsMouseDown(0));
            }

            if (action == BoneGizmoAction.Rotate)
            {
                return(m_GUIWapper.IsMouseDown(0));
            }

            if (action == BoneGizmoAction.Move)
            {
                return(m_GUIWapper.IsMouseDown(0));
            }

            return(false);
        }
示例#4
0
        public void OnGUI()
        {
            m_ControlID = m_GUIWrapper.GetControlID(kBrushHashCode, FocusType.Passive);

            var eventType = m_GUIWrapper.eventType;

            if (!m_GUIWrapper.isAltDown)
            {
                m_GUIWrapper.LayoutControl(controlID, 0f);
            }

            if (isActivable)
            {
                m_SliderData.position = m_GUIWrapper.GUIToWorld(m_GUIWrapper.mousePosition);

                if (m_GUIWrapper.IsMouseDown(0))
                {
                    m_DeltaAcc = 0f;
                    onStrokeBegin(this);
                    onStrokeStep(this);
                    m_GUIWrapper.SetGuiChanged(true);
                }

                if (eventType == EventType.MouseMove)
                {
                    onMove(this);
                    m_GUIWrapper.UseCurrentEvent();
                }

                if (m_GUIWrapper.isShiftDown && eventType == EventType.ScrollWheel)
                {
                    var sizeDelta = HandleUtility.niceMouseDeltaZoom * kWheelSizeSpeed;
                    size = Mathf.Max(1f, size + sizeDelta);
                    onSize(this);
                    m_GUIWrapper.UseCurrentEvent();
                }
            }

            if (isHot && m_GUIWrapper.IsMouseUp(0))
            {
                onStrokeEnd(this);
            }

            if (m_GUIWrapper.IsRepainting() && (isHot || isActivable))
            {
                onRepaint(this);
            }

            Vector3 position;

            if (m_GUIWrapper.DoSlider(m_ControlID, m_SliderData, out position))
            {
                step = Mathf.Max(step, 1f);

                var delta     = position - m_SliderData.position;
                var direction = delta.normalized;
                var magnitude = delta.magnitude;

                m_SliderData.position -= direction * m_DeltaAcc;

                m_DeltaAcc += magnitude;

                if (m_DeltaAcc >= step)
                {
                    var stepVector = direction * step;

                    while (m_DeltaAcc >= step)
                    {
                        m_SliderData.position += stepVector;

                        onMove(this);
                        onStrokeStep(this);

                        m_DeltaAcc -= step;
                    }
                }

                m_SliderData.position = position;
                onStrokeDelta(this);
            }
        }