public static Vector2 ScaleSlider(int id, Vector2 pos, UnityEditor.MouseCursor cursor, Rect cursorRect) { Vector2 b = Handles.matrix.MultiplyPoint(pos); Event current = Event.current; switch (current.GetTypeForControl(id)) { case EventType.MouseDown: if (current.button == 0 && cursorRect.Contains(Event.current.mousePosition) && !current.alt) { GUIUtility.keyboardControl = id; GUIUtility.hotControl = id; SVGEditorHandles.s_CurrentMousePosition = current.mousePosition; SVGEditorHandles.s_DragStartScreenPosition = current.mousePosition; SVGEditorHandles.s_DragScreenOffset = SVGEditorHandles.s_CurrentMousePosition - b; current.Use(); EditorGUIUtility.SetWantsMouseJumping(1); } break; case EventType.MouseUp: if (GUIUtility.hotControl == id && (current.button == 0 || current.button == 2)) { GUIUtility.hotControl = 0; current.Use(); EditorGUIUtility.SetWantsMouseJumping(0); } break; case EventType.MouseDrag: if (GUIUtility.hotControl == id) { SVGEditorHandles.s_CurrentMousePosition += current.delta; Vector2 a = pos; pos = Handles.inverseMatrix.MultiplyPoint(SVGEditorHandles.s_CurrentMousePosition); if (!Mathf.Approximately((a - pos).magnitude, 0f)) { GUI.changed = true; } current.Use(); } break; case EventType.KeyDown: if (GUIUtility.hotControl == id && current.keyCode == KeyCode.Escape) { pos = Handles.inverseMatrix.MultiplyPoint(SVGEditorHandles.s_DragStartScreenPosition - SVGEditorHandles.s_DragScreenOffset); GUIUtility.hotControl = 0; GUI.changed = true; current.Use(); } break; case EventType.Repaint: EditorGUIUtility.AddCursorRect(cursorRect, cursor, id); break; } return(pos); }
public static Vector2 PointSlider(Vector2 pos, UnityEditor.MouseCursor cursor, GUIStyle dragDot, GUIStyle dragDotActive) { int controlID = GUIUtility.GetControlID("Slider1D".GetHashCode(), FocusType.Keyboard); Vector2 vector = Handles.matrix.MultiplyPoint(pos); Rect rect = new Rect(vector.x - dragDot.fixedWidth * 0.5f, vector.y - dragDot.fixedHeight * 0.5f, dragDot.fixedWidth, dragDot.fixedHeight); Event current = Event.current; EventType typeForControl = current.GetTypeForControl(controlID); if (typeForControl == EventType.Repaint) { if (GUIUtility.hotControl == controlID) { dragDotActive.Draw(rect, GUIContent.none, controlID); } else { dragDot.Draw(rect, GUIContent.none, controlID); } } return(SVGEditorHandles.ScaleSlider(pos, cursor, rect)); }
public static Vector2 ScaleSlider(Vector2 pos, UnityEditor.MouseCursor cursor, Rect cursorRect) { int controlID = GUIUtility.GetControlID("Slider1D".GetHashCode(), FocusType.Keyboard); return(SVGEditorHandles.ScaleSlider(controlID, pos, cursor, cursorRect)); }
public static void AddCursorRect(Rect position, UnityEditor.MouseCursor mouse, int controlID) { EditorGUIUtility.AddCursorRect(position, mouse, controlID); }
public static void AddCursorRect(Rect position, UnityEditor.MouseCursor mouse) { EditorGUIUtility.AddCursorRect(position, mouse); }
static KeyValuePair <int, Tuple <Rect, ComputeResize> > CreateResizeHandleControl(Rect activeRect, String suffix, Rect parentWindowRect, UnityEditor.MouseCursor cursor, ComputeResize resizeDelegate) { int id = GUIUtility.GetControlID(("ProBuilderWindowResize" + suffix).GetHashCode(), FocusType.Passive, parentWindowRect); HandleUtility.AddControl(id, Vector2.Distance(activeRect.center, Event.current.mousePosition)); UnityEditor.EditorGUIUtility.AddCursorRect(activeRect, cursor); return(new KeyValuePair <int, Tuple <Rect, ComputeResize> >(id, new Tuple <Rect, ComputeResize>(activeRect, resizeDelegate))); }