static bool SurfaceSelection(Rect dragArea, SelectionType selectionType) { var id = GUIUtility.GetControlID(kSurfaceDragSelectionHash, FocusType.Keyboard, dragArea); bool repaint = false; var evt = Event.current; if (evt.type == EventType.MouseMove || evt.type == EventType.MouseDown) { if (UpdateHoverSurfaces(evt.mousePosition, dragArea, selectionType, true)) { repaint = true; } if (!InEditCameraMode) { return(repaint); } } if (InEditCameraMode && !ToolIsDragging) { if (MouseIsDown) { CSGOutlineRenderer.VisualizationMode = VisualizationMode.None; } else { CSGOutlineRenderer.VisualizationMode = VisualizationMode.Surface | VisualizationMode.Outline; } } else { CSGOutlineRenderer.VisualizationMode = VisualizationMode.None; } switch (evt.GetTypeForControl(id)) { case EventType.Layout: { // we only do drag selection when we use a modifier (shift, control etc.) if (selectionType == SelectionType.Replace) { break; } if (hoverSurfaces != null && hoverSurfaces.Count > 0) { HandleUtility.AddControl(id, 3.0f); } break; } case EventType.MouseDown: { if (GUIUtility.hotControl != 0) { break; } // we only do drag selection when we use a modifier (shift, control etc.) if (selectionType == SelectionType.Replace) { break; } if ((UnityEditor.HandleUtility.nearestControl != id || evt.button != 0) && (GUIUtility.keyboardControl != id || evt.button != 2)) { break; } GUIUtility.hotControl = GUIUtility.keyboardControl = id; evt.Use(); break; } case EventType.MouseDrag: { if (GUIUtility.hotControl != id) { break; } UpdateHoverSurfaces(evt.mousePosition, dragArea, selectionType, false); evt.Use(); break; } case EventType.MouseUp: { if (GUIUtility.hotControl != id || evt.button != 0) { break; } GUIUtility.hotControl = 0; GUIUtility.keyboardControl = 0; evt.Use(); if (CSGSurfaceSelectionManager.UpdateSelection(selectionType, hoverSurfaces)) { repaint = true; } if (UpdateHoverSurfaces(evt.mousePosition, dragArea, selectionType, true)) { repaint = true; } break; } } return(repaint); }
static bool ClickSelection(Rect dragArea, SelectionType selectionType) { return(CSGSurfaceSelectionManager.UpdateSelection(selectionType, hoverSurfaces)); }