private void HandleBrushPicking() { Event evt = Event.current; if (evt.type == EventType.MouseDown && IsPickingEvent(evt) && !isHotControl) { m_ModeBeforePicking = EditMode.SceneViewEditMode.GridPainting; if (inEditMode && EditMode.editMode != EditMode.SceneViewEditMode.GridPicking) { m_ModeBeforePicking = EditMode.editMode; EditMode.ChangeEditMode(EditMode.SceneViewEditMode.GridPicking, GridPaintingState.instance); } m_MarqueeStart = mouseGridPosition; m_MarqueeType = MarqueeType.Pick; s_LastActivePaintableGrid = this; Event.current.Use(); GUI.changed = true; GUIUtility.hotControl = m_PermanentControlID; OnBrushPickStarted(); } if (evt.type == EventType.MouseDrag && isHotControl && m_MarqueeStart.HasValue && m_MarqueeType == MarqueeType.Pick && IsPickingEvent(evt)) { RectInt rect = GridEditorUtility.GetMarqueeRect(m_MarqueeStart.Value, mouseGridPosition); OnBrushPickDragged(new BoundsInt(new Vector3Int(rect.xMin, rect.yMin, 0), new Vector3Int(rect.size.x, rect.size.y, 1))); Event.current.Use(); GUI.changed = true; } if (evt.rawType == EventType.MouseUp && isHotControl && m_MarqueeStart.HasValue && m_MarqueeType == MarqueeType.Pick && IsPickingEvent(evt)) { // Check if event only occurred in the PaintableGrid window as evt.type will filter for this if (evt.type == EventType.MouseUp && m_MarqueeType == MarqueeType.Pick) { RectInt rect = GridEditorUtility.GetMarqueeRect(m_MarqueeStart.Value, mouseGridPosition); Vector2Int pivot = GetMarqueePivot(m_MarqueeStart.Value, mouseGridPosition); PickBrush(new BoundsInt(new Vector3Int(rect.xMin, rect.yMin, 0), new Vector3Int(rect.size.x, rect.size.y, 1)), new Vector3Int(pivot.x, pivot.y, 0)); if (inEditMode && EditMode.editMode != m_ModeBeforePicking) { EditMode.ChangeEditMode(m_ModeBeforePicking, GridPaintingState.instance); } GridPaletteBrushes.ActiveGridBrushAssetChanged(); s_LastActivePaintableGrid = this; Event.current.Use(); GUI.changed = true; } else // Event occurred outside of PaintableGrid window, cancel the pick event { OnBrushPickCancelled(); } m_MarqueeType = MarqueeType.None; m_MarqueeStart = null; GUIUtility.hotControl = 0; InspectorWindow.RepaintAllInspectors(); } }
private void HandleBrushPicking() { Event current = Event.current; if (current.type == EventType.MouseDown && this.IsPickingEvent(current) && !this.isHotControl) { this.m_ModeBeforePicking = EditMode.SceneViewEditMode.GridPainting; if (this.inEditMode && EditMode.editMode != EditMode.SceneViewEditMode.GridPicking) { this.m_ModeBeforePicking = EditMode.editMode; EditMode.ChangeEditMode(EditMode.SceneViewEditMode.GridPicking, ScriptableSingleton <GridPaintingState> .instance); } this.m_MarqueeStart = new Vector2Int?(this.mouseGridPosition); this.m_MarqueeType = PaintableGrid.MarqueeType.Pick; PaintableGrid.s_LastActivePaintableGrid = this; Event.current.Use(); GUI.changed = true; GUIUtility.hotControl = this.m_PermanentControlID; this.OnBrushPickStarted(); } if (current.type == EventType.MouseDrag && this.isHotControl && this.m_MarqueeStart.HasValue && this.m_MarqueeType == PaintableGrid.MarqueeType.Pick && this.IsPickingEvent(current)) { RectInt marqueeRect = GridEditorUtility.GetMarqueeRect(this.m_MarqueeStart.Value, this.mouseGridPosition); this.OnBrushPickDragged(new BoundsInt(new Vector3Int(marqueeRect.xMin, marqueeRect.yMin, 0), new Vector3Int(marqueeRect.size.x, marqueeRect.size.y, 1))); Event.current.Use(); GUI.changed = true; } if (current.type == EventType.MouseUp && this.m_MarqueeStart.HasValue && this.m_MarqueeType == PaintableGrid.MarqueeType.Pick && this.IsPickingEvent(current)) { RectInt marqueeRect2 = GridEditorUtility.GetMarqueeRect(this.m_MarqueeStart.Value, this.mouseGridPosition); if (this.isHotControl) { Vector2Int marqueePivot = this.GetMarqueePivot(this.m_MarqueeStart.Value, this.mouseGridPosition); this.PickBrush(new BoundsInt(new Vector3Int(marqueeRect2.xMin, marqueeRect2.yMin, 0), new Vector3Int(marqueeRect2.size.x, marqueeRect2.size.y, 1)), new Vector3Int(marqueePivot.x, marqueePivot.y, 0)); if (this.inEditMode && EditMode.editMode != this.m_ModeBeforePicking) { EditMode.ChangeEditMode(this.m_ModeBeforePicking, ScriptableSingleton <GridPaintingState> .instance); } GridPaletteBrushes.ActiveGridBrushAssetChanged(); PaintableGrid.s_LastActivePaintableGrid = this; InspectorWindow.RepaintAllInspectors(); Event.current.Use(); GUI.changed = true; GUIUtility.hotControl = 0; } this.m_MarqueeType = PaintableGrid.MarqueeType.None; this.m_MarqueeStart = null; } }
private void OnBrushInspectorGUI() { GridBrushBase gridBrush = GridPaintingState.gridBrush; if (!(gridBrush == null)) { EditorGUI.BeginChangeCheck(); if (GridPaintingState.activeBrushEditor != null) { GridPaintingState.activeBrushEditor.OnPaintInspectorGUI(); } else if (GridPaintingState.fallbackEditor != null) { GridPaintingState.fallbackEditor.OnInspectorGUI(); } if (EditorGUI.EndChangeCheck()) { GridPaletteBrushes.ActiveGridBrushAssetChanged(); } } }