private void DrawListViewDrag(Rect dragRect) { EGUI.DrawVerticalLine(dragRect, Color.grey, 2.0f); EditorGUIUtility.AddCursorRect(dragRect, MouseCursor.ResizeHorizontal); if (Event.current != null) { if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && dragRect.Contains(Event.current.mousePosition)) { isListViewDragging = true; Event.current.Use(); Repaint(); } else if (isListViewDragging && Event.current.type == EventType.MouseDrag) { listViewWidth += Event.current.delta.x; if (listViewWidth < MIN_LISTVIEW_WIDTH) { listViewWidth = MIN_LISTVIEW_WIDTH; } else if (listViewWidth > MAX_LISTVIEW_WIDTH) { listViewWidth = MAX_LISTVIEW_WIDTH; } Repaint(); } else if (isListViewDragging && Event.current.type == EventType.MouseUp) { isListViewDragging = false; Event.current.Use(); Repaint(); } } }
private void DrawPropertyDrag(Rect dragRect) { EGUI.DrawVerticalLine(dragRect, Color.grey, 2.0f); EditorGUIUtility.AddCursorRect(dragRect, MouseCursor.ResizeHorizontal); if (Event.current != null) { if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && dragRect.Contains(Event.current.mousePosition)) { isPropertyDragging = true; Event.current.Use(); Window.Repaint(); } else if (isPropertyDragging && Event.current.type == EventType.MouseDrag) { propertyWidth -= Event.current.delta.x; if (propertyWidth < MIN_PROPERTY_WIDTH) { propertyWidth = MIN_PROPERTY_WIDTH; } else if (propertyWidth > MAX_PROPERTY_WIDTH) { propertyWidth = MAX_PROPERTY_WIDTH; } Window.Repaint(); } else if (isPropertyDragging && Event.current.type == EventType.MouseUp) { isPropertyDragging = false; Event.current.Use(); Window.Repaint(); } } }
public void OnGUILayout() { if (direction == DragLineDirection.Horizontal) { if (position.height < 2.0f) { position.height = 2.0f; } if (LowLimitXY > 0.0f && position.y < LowLimitXY) { position.y = LowLimitXY; } else if (UpperLimitXY > 0.0f && position.y + position.height > UpperLimitXY) { position.y = UpperLimitXY - position.height; } EGUI.DrawHorizontalLine(position, Color.grey); EditorGUIUtility.AddCursorRect(position, MouseCursor.ResizeVertical); } else if (direction == DragLineDirection.Vertical) { if (position.width < 2.0f) { position.width = 2.0f; } if (LowLimitXY > 0.0f && position.x < LowLimitXY) { position.x = LowLimitXY; } else if (UpperLimitXY > 0.0f && position.x + position.width > UpperLimitXY) { position.x = UpperLimitXY - position.width; } EGUI.DrawVerticalLine(position, Color.grey); EditorGUIUtility.AddCursorRect(position, MouseCursor.ResizeHorizontal); } if (Event.current != null) { if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && position.Contains(Event.current.mousePosition)) { isDragging = true; Event.current.Use(); } else if (isDragging && Event.current.type == EventType.MouseDrag) { if (direction == DragLineDirection.Horizontal) { position.y += Event.current.delta.y; } else if (direction == DragLineDirection.Vertical) { position.x += Event.current.delta.x; } window.Repaint(); } else if (isDragging && Event.current.type == EventType.MouseUp) { isDragging = false; Event.current.Use(); } } }