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); }
public bool IsActionFinishing(SkeletonAction action) { if (!IsActionHot(action) || !IsCapable(action)) { return(false); } if (m_GUIWrapper.IsEventOutsideWindow()) { return(true); } if (action == SkeletonAction.CreateBone) { return(m_GUIWrapper.IsMouseDown(0)); } return(m_GUIWrapper.IsMouseUp(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); } }