Beispiel #1
0
        public void BeginLayout()
        {
            m_HoveredBodyControlID  = m_GUIWrapper.GetControlID(kBodyHashCode, FocusType.Passive);
            m_HoveredJointControlID = m_GUIWrapper.GetControlID(kJointHashCode, FocusType.Passive);
            m_HoveredTailControlID  = m_GUIWrapper.GetControlID(kTailHashCode, FocusType.Passive);
            m_CreateBoneControlID   = m_GUIWrapper.GetControlID(kCreateBoneHashCode, FocusType.Passive);

            if (m_GUIWrapper.eventType == EventType.Layout)
            {
                m_PrevHoveredBoneID    = m_HoveredBoneID;
                m_NearestDistance      = float.MaxValue;
                m_NearestBodyDistance  = float.MaxValue;
                m_NearestJointDistance = float.MaxValue;
                m_NearestTailDistance  = float.MaxValue;
                m_NearestBodyId        = InvalidID;
                m_NearestJointId       = InvalidID;
                m_NearestTailId        = InvalidID;
                m_HoveredBoneID        = InvalidID;
                m_HoveredBodyID        = InvalidID;
                m_HoveredJointID       = InvalidID;
                m_HoveredTailID        = InvalidID;
                m_HoveredSliderData    = SliderData.zero;

                if (m_GUIWrapper.IsControlHot(0))
                {
                    m_RotateControlID          = -1;
                    m_MoveControlID            = -1;
                    m_FreeMoveControlID        = -1;
                    m_MoveJointControlID       = -1;
                    m_MoveEndPositionControlID = -1;
                    m_ChangeLengthControlID    = -1;
                    m_HotBoneID = InvalidID;
                }
            }
        }
Beispiel #2
0
        public void SetupLayout()
        {
            if (m_GUIWapper.eventType == EventType.Layout)
            {
                m_HoveredBoneBodyControlID = -1;
                m_HoveredBoneHeadControlID = -1;
                m_HoveredBoneTransform     = null;

                if (m_GUIWapper.IsControlHot(0))
                {
                    m_RotateBoneControlID = -1;
                    m_MoveBoneControlID   = -1;
                    m_HotBoneTransform    = null;
                }
            }
        }
        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_GUIWrapper.IsControlHot(state.hotControl).Returns(true);
            m_GUIWrapper.IsViewToolActive().Returns(x => state.viewToolActive);
        }
Beispiel #4
0
        public void SetupBase()
        {
            m_EventType        = EventType.Layout;
            m_NearestDistance  = kPickDistance;
            m_NearestControl   = GetDefaultControlID();
            m_CurrentControlID = 0;
            m_MousePosition    = Vector2.zero;
            m_HotControl       = 0;

            m_GUIWrapper = Substitute.For <IGUIWrapper>();
            m_GUIWrapper.GetControlID(Arg.Any <int>(), Arg.Any <FocusType>()).Returns(x => GetControlID((int)x[0], (FocusType)x[1]));
            m_GUIWrapper.mousePosition.Returns(x => m_MousePosition);
            m_GUIWrapper.eventType.Returns(x => m_EventType);
            m_GUIWrapper.GUIToWorld(Arg.Any <Vector2>()).Returns(x => (Vector3)(Vector2)x[0]);
            m_GUIWrapper.GUIToWorld(Arg.Any <Vector2>(), Arg.Any <Vector3>(), Arg.Any <Vector3>()).Returns(x => (Vector3)(Vector2)x[0]);
            m_GUIWrapper.IsControlNearest(Arg.Any <int>()).Returns(x => (int)x[0] == nearestControl);
            m_GUIWrapper.IsControlHot(Arg.Any <int>()).Returns(x => (int)x[0] == m_HotControl);
            m_GUIWrapper.When(x => m_GUIWrapper.LayoutControl(Arg.Any <int>(), Arg.Any <float>())).Do(x =>
            {
                if (m_EventType != EventType.Layout)
                {
                    return;
                }

                int controlId  = (int)x[0];
                float distance = (float)x[1];

                if (distance <= m_NearestDistance)
                {
                    m_NearestDistance = distance;
                    m_NearestControl  = controlId;
                }
            });
            m_GUIWrapper.DistanceToCircle(Arg.Any <Vector3>(), Arg.Any <float>()).Returns(x =>
            {
                Vector2 center = (Vector3)x[0];
                float radius   = (float)x[1];

                float dist = (center - m_MousePosition).magnitude;
                if (dist < radius)
                {
                    return(0f);
                }
                return(dist - radius);
            });
            m_GUIWrapper.DistanceToSegment(Arg.Any <Vector3>(), Arg.Any <Vector3>()).Returns(x => HandleUtility.DistancePointToLineSegment(m_MousePosition, (Vector3)x[0], (Vector3)x[1]));
            m_GUIWrapper.DistanceToSegmentClamp(Arg.Any <Vector3>(), Arg.Any <Vector3>()).Returns(x => MathUtility.DistanceToSegmentClamp(m_MousePosition, (Vector3)x[0], (Vector3)x[1]));

            Vector3 sliderPos;

            m_GUIWrapper.DoSlider(Arg.Any <int>(), Arg.Any <SliderData>(), out sliderPos).ReturnsForAnyArgs(x => (int)x[0] == nearestControl);
            m_GUIWrapper.GetHandleSize(Arg.Any <Vector3>()).ReturnsForAnyArgs(x => 1f);
        }