コード例 #1
0
        void CallOnPaintSceneGUI()
        {
            bool hasSelection = GridSelection.active && GridSelection.target == brushTarget;

            if (!hasSelection && GridPaintingState.activeGrid != this)
            {
                return;
            }

            RectInt rect = new RectInt(mouseGridPosition, new Vector2Int(1, 1));

            if (m_MarqueeStart.HasValue)
            {
                rect = GridEditorUtility.GetMarqueeRect(mouseGridPosition, m_MarqueeStart.Value);
            }
            else if (hasSelection)
            {
                rect = new RectInt(GridSelection.position.xMin, GridSelection.position.yMin, GridSelection.position.size.x, GridSelection.position.size.y);
            }

            var       layoutGrid  = tilemap != null ? tilemap : grid as GridLayout;
            BoundsInt brushBounds = new BoundsInt(new Vector3Int(rect.x, rect.y, zPosition), new Vector3Int(rect.width, rect.height, 1));

            if (GridPaintingState.activeBrushEditor != null)
            {
                GridPaintingState.activeBrushEditor.OnPaintSceneGUI(layoutGrid, brushTarget, brushBounds
                                                                    , EditTypeToBrushTool(EditorTools.EditorTools.activeToolType), m_MarqueeStart.HasValue || executing);
            }
            else // Fallback when user hasn't defined custom editor
            {
                GridBrushEditorBase.OnPaintSceneGUIInternal(layoutGrid, brushTarget, brushBounds
                                                            , EditTypeToBrushTool(EditorTools.EditorTools.activeToolType), m_MarqueeStart.HasValue || executing);
            }
        }
コード例 #2
0
        private void RenderGrid()
        {
            // MeshTopology.Lines doesn't give nice pixel perfect grid so we have to have separate codepath with MeshTopology.Quads specially for palette window here
            if (m_GridMesh == null && grid.cellLayout == GridLayout.CellLayout.Rectangle)
            {
                m_GridMesh = GridEditorUtility.GenerateCachedGridMesh(grid, k_GridColor, 1f / LocalToScreenRatio(), paddedBoundsInt, MeshTopology.Quads);
            }

            GridEditorUtility.DrawGridGizmo(grid, grid.transform, k_GridColor, ref m_GridMesh, ref m_GridMaterial);
        }
コード例 #3
0
        private static void DrawGrid(GridLayout gridLayout)
        {
            int gridHash = GenerateHash(gridLayout, sceneViewGridComponentGizmo.Color);

            if (s_LastGridProxyHash != gridHash)
            {
                FlushCachedGridProxy();
                s_LastGridProxyHash = gridHash;
            }
            GridEditorUtility.DrawGridGizmo(gridLayout, gridLayout.transform, sceneViewGridComponentGizmo.Color, ref s_GridProxyMesh, ref s_GridProxyMaterial);
        }
コード例 #4
0
        internal static RectInt GetMinMaxRect(List <Vector2Int> positions)
        {
            if (positions == null || positions.Count == 0)
            {
                return(new RectInt());
            }

            return(GridEditorUtility.GetMarqueeRect(
                       new Vector2Int(positions.Min(p1 => p1.x), positions.Min(p1 => p1.y)),
                       new Vector2Int(positions.Max(p1 => p1.x), positions.Max(p1 => p1.y))
                       ));
        }
コード例 #5
0
        private void RenderDragAndDropPreview()
        {
            if (!activeDragAndDrop || m_HoverData == null || m_HoverData.Count == 0)
            {
                return;
            }

            RectInt rect = TileDragAndDrop.GetMinMaxRect(m_HoverData.Keys.ToList());

            rect.position         += mouseGridPosition;
            DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
            GridEditorUtility.DrawGridMarquee(grid, new BoundsInt(new Vector3Int(rect.xMin, rect.yMin, zPosition), new Vector3Int(rect.width, rect.height, 1)), Color.white);
        }
コード例 #6
0
        internal static void OnPaintSceneGUIInternal(GridLayout gridLayout, GameObject brushTarget, BoundsInt position, GridBrushBase.Tool tool, bool executing)
        {
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }

            Color color = Color.white;

            if (tool == GridBrushBase.Tool.Pick && executing)
            {
                color = Color.cyan;
            }
            if (tool == GridBrushBase.Tool.Paint && executing)
            {
                color = Color.yellow;
            }

            if (tool == GridBrushBase.Tool.Select ||
                tool == GridBrushBase.Tool.Move)
            {
                if (executing)
                {
                    color = Styles.executingColor;
                }
                else if (GridSelection.active)
                {
                    color = Styles.activeColor;
                }
            }

            if (brushTarget != null)
            {
                var targetLayout = brushTarget.GetComponent <GridLayout>();
                if (targetLayout != null)
                {
                    gridLayout = targetLayout;
                }
            }

            if (position.zMin != 0)
            {
                var zeroBounds = position;
                zeroBounds.z = 0;
                GridEditorUtility.DrawGridMarquee(gridLayout, zeroBounds, color);
                color = Color.blue;
            }
            GridEditorUtility.DrawGridMarquee(gridLayout, position, color);
        }
コード例 #7
0
        private void CallOnPaintSceneGUI(Vector2Int position)
        {
            if (!unlocked && !TilemapEditorTool.IsActive(typeof(SelectTool)) && !TilemapEditorTool.IsActive(typeof(PickingTool)))
            {
                return;
            }

            bool hasSelection = GridSelection.active && GridSelection.target == brushTarget;

            if (!hasSelection && GridPaintingState.activeGrid != this)
            {
                return;
            }

            GridBrushBase brush = GridPaintingState.gridBrush;

            if (brush == null)
            {
                return;
            }

            var rect = new RectInt(position, new Vector2Int(1, 1));

            if (m_MarqueeStart.HasValue)
            {
                rect = GridEditorUtility.GetMarqueeRect(position, m_MarqueeStart.Value);
            }
            else if (hasSelection)
            {
                rect = new RectInt(GridSelection.position.xMin, GridSelection.position.yMin, GridSelection.position.size.x, GridSelection.position.size.y);
            }

            var       gridLayout  = tilemap != null ? tilemap.layoutGrid : grid as GridLayout;
            BoundsInt brushBounds = new BoundsInt(new Vector3Int(rect.x, rect.y, zPosition), new Vector3Int(rect.width, rect.height, 1));

            if (GridPaintingState.activeBrushEditor != null)
            {
                GridPaintingState.activeBrushEditor.OnPaintSceneGUI(gridLayout, brushTarget, brushBounds,
                                                                    EditTypeToBrushTool(UnityEditor.EditorTools.ToolManager.activeToolType),
                                                                    m_MarqueeStart.HasValue || executing);
            }
            else // Fallback when user hasn't defined custom editor
            {
                GridBrushEditorBase.OnPaintSceneGUIInternal(gridLayout, Selection.activeGameObject, brushBounds,
                                                            EditTypeToBrushTool(UnityEditor.EditorTools.ToolManager.activeToolType),
                                                            m_MarqueeStart.HasValue || executing);
            }
        }
コード例 #8
0
 protected override Vector2Int ScreenToGrid(Vector2 screenPosition)
 {
     if (tilemap != null)
     {
         var        transform = tilemap.transform;
         Plane      plane     = new Plane(GetGridForward(tilemap), transform.position);
         Vector3Int cell      = LocalToGrid(tilemap, GridEditorUtility.ScreenToLocal(transform, screenPosition, plane));
         return(new Vector2Int(cell.x, cell.y));
     }
     if (grid != null)
     {
         Vector3Int cell = LocalToGrid(grid, GridEditorUtility.ScreenToLocal(gridTransform, screenPosition, GetGridPlane(grid)));
         return(new Vector2Int(cell.x, cell.y));
     }
     return(Vector2Int.zero);
 }
コード例 #9
0
        protected void DrawSelectionGizmo(RectInt rect)
        {
            if (Event.current.type != EventType.Repaint || !GUI.enabled)
            {
                return;
            }

            Color color = Color.white;

            if (isPicking)
            {
                color = Color.cyan;
            }

            GridEditorUtility.DrawGridMarquee(grid, new BoundsInt(new Vector3Int(rect.xMin, rect.yMin, 0), new Vector3Int(rect.width, rect.height, 1)), color);
        }
コード例 #10
0
        internal static void OnSceneGUIInternal(GridLayout gridLayout, GameObject brushTarget, BoundsInt position, GridBrushBase.Tool tool, bool executing)
        {
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }

            if (tool == GridBrushBase.Tool.Select ||
                tool == GridBrushBase.Tool.Move)
            {
                if (GridSelection.active && !executing)
                {
                    Color color = Styles.activeColor;
                    GridEditorUtility.DrawGridMarquee(gridLayout, position, color);
                }
            }
        }
コード例 #11
0
        private void HandleBoxTool()
        {
            Event evt = Event.current;

            if (evt.type == EventType.MouseDown && evt.button == 0 && !evt.alt && TilemapEditorTool.IsActive(typeof(BoxTool)))
            {
                m_MarqueeStart = mouseGridPosition;
                m_MarqueeType  = MarqueeType.Box;
                Event.current.Use();
                GUI.changed           = true;
                executing             = true;
                GUIUtility.hotControl = m_PermanentControlID;
            }
            if (evt.type == EventType.MouseDrag && evt.button == 0 && TilemapEditorTool.IsActive(typeof(BoxTool)))
            {
                if (isHotControl && m_MarqueeStart.HasValue)
                {
                    Event.current.Use();
                    executing   = true;
                    GUI.changed = true;
                }
            }
            if (evt.type == EventType.MouseUp && evt.button == 0 && TilemapEditorTool.IsActive(typeof(BoxTool)))
            {
                if (isHotControl && m_MarqueeStart.HasValue)
                {
                    RegisterUndo();
                    RectInt rect = GridEditorUtility.GetMarqueeRect(m_MarqueeStart.Value, mouseGridPosition);
                    if (evt.shift)
                    {
                        BoxErase(new BoundsInt(rect.x, rect.y, zPosition, rect.size.x, rect.size.y, 1));
                    }
                    else
                    {
                        BoxFill(new BoundsInt(rect.x, rect.y, zPosition, rect.size.x, rect.size.y, 1));
                    }
                    Event.current.Use();
                    executing             = false;
                    GUI.changed           = true;
                    GUIUtility.hotControl = 0;
                }
                m_MarqueeStart = null;
                m_MarqueeType  = MarqueeType.None;
            }
        }
コード例 #12
0
        private void HandleSelectTool()
        {
            Event evt = Event.current;

            if (evt.type == EventType.MouseDown && evt.button == 0 && !evt.alt && (TilemapEditorTool.IsActive(typeof(SelectTool)) || (TilemapEditorTool.IsActive(typeof(MoveTool)) && evt.control)))
            {
                if (TilemapEditorTool.IsActive(typeof(MoveTool)) && evt.control)
                {
                    TilemapEditorTool.SetActiveEditorTool(typeof(SelectTool));
                }

                m_PreviousMove = null;
                m_MarqueeStart = mouseGridPosition;
                m_MarqueeType  = MarqueeType.Select;

                s_LastActivePaintableGrid = this;
                GUIUtility.hotControl     = m_PermanentControlID;
                Event.current.Use();
            }
            if (evt.rawType == EventType.MouseUp && evt.button == 0 && !evt.alt && m_MarqueeStart.HasValue && isHotControl && TilemapEditorTool.IsActive(typeof(SelectTool)))
            {
                // Check if event only occurred in the PaintableGrid window as evt.type will filter for this
                if (evt.type == EventType.MouseUp && m_MarqueeType == MarqueeType.Select)
                {
                    RectInt rect = GridEditorUtility.GetMarqueeRect(m_MarqueeStart.Value, mouseGridPosition);
                    Select(new BoundsInt(new Vector3Int(rect.xMin, rect.yMin, zPosition), new Vector3Int(rect.size.x, rect.size.y, 1)));
                    Event.current.Use();
                }
                if (evt.control)
                {
                    TilemapEditorTool.SetActiveEditorTool(typeof(MoveTool));
                }
                m_MarqueeStart = null;
                m_MarqueeType  = MarqueeType.None;
                InspectorWindow.RepaintAllInspectors();
                GUIUtility.hotControl = 0;
            }
            if (evt.type == EventType.KeyDown && evt.keyCode == KeyCode.Escape && !m_MarqueeStart.HasValue && !m_PreviousMove.HasValue)
            {
                ClearGridSelection();
                Event.current.Use();
            }
        }
コード例 #13
0
        internal static RectInt GetBounds(GameObject palette)
        {
            if (palette == null)
            {
                return(new RectInt());
            }

            Vector2Int min = new Vector2Int(int.MaxValue, int.MaxValue);
            Vector2Int max = new Vector2Int(int.MinValue, int.MinValue);

            foreach (var tilemap in palette.GetComponentsInChildren <Tilemap>())
            {
                Vector3Int p1         = tilemap.editorPreviewOrigin;
                Vector3Int p2         = p1 + tilemap.editorPreviewSize;
                Vector2Int tilemapMin = new Vector2Int(Mathf.Min(p1.x, p2.x), Mathf.Min(p1.y, p2.y));
                Vector2Int tilemapMax = new Vector2Int(Mathf.Max(p1.x, p2.x), Mathf.Max(p1.y, p2.y));
                min = new Vector2Int(Mathf.Min(min.x, tilemapMin.x), Mathf.Min(min.y, tilemapMin.y));
                max = new Vector2Int(Mathf.Max(max.x, tilemapMax.x), Mathf.Max(max.y, tilemapMax.y));
            }

            return(GridEditorUtility.GetMarqueeRect(min, max));
        }
コード例 #14
0
        private void HandleBrushPicking()
        {
            Event evt = Event.current;

            if (evt.type == EventType.MouseDown && IsPickingEvent(evt) && !isHotControl)
            {
                m_TypeBeforeExecution = typeof(PaintTool);
                if (inEditMode && !TilemapEditorTool.IsActive(typeof(PickingTool)))
                {
                    m_TypeBeforeExecution = UnityEditor.EditorTools.ToolManager.activeToolType;
                    TilemapEditorTool.SetActiveEditorTool(typeof(PickingTool));
                }

                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, zPosition), 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, zPosition), new Vector3Int(rect.size.x, rect.size.y, 1)), new Vector3Int(pivot.x, pivot.y, 0));

                    if (inEditMode && UnityEditor.EditorTools.ToolManager.activeToolType != m_TypeBeforeExecution)
                    {
                        if (PickingIsDefaultTool() &&
                            (m_TypeBeforeExecution == typeof(EraseTool) ||
                             m_TypeBeforeExecution == typeof(MoveTool)))
                        {
                            // If Picking is default, change to a Paint Tool to facilitate editing if previous tool does not allow for painting
                            TilemapEditorTool.SetActiveEditorTool(typeof(PaintTool));
                        }
                        else
                        {
                            TilemapEditorTool.SetActiveEditorTool(m_TypeBeforeExecution);
                        }
                    }

                    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();
            }
        }
コード例 #15
0
        private void HandleBrushPaintAndErase()
        {
            Event evt = Event.current;

            if (!IsPaintingEvent(evt) && !IsErasingEvent(evt))
            {
                return;
            }

            switch (evt.type)
            {
            case EventType.MouseDown:
                RegisterUndo();
                GUIUtility.hotControl = m_PermanentControlID;
                executing             = true;
                m_TypeBeforeExecution = EditorTools.ToolManager.activeToolType;
                if (IsErasingEvent(evt))
                {
                    if (!TilemapEditorTool.IsActive(typeof(EraseTool)))
                    {
                        TilemapEditorTool.SetActiveEditorTool(typeof(EraseTool));
                    }
                    Erase(new Vector3Int(mouseGridPosition.x, mouseGridPosition.y, zPosition));
                }
                else
                {
                    if (!TilemapEditorTool.IsActive(typeof(PaintTool)))
                    {
                        TilemapEditorTool.SetActiveEditorTool(typeof(PaintTool));
                    }
                    Paint(new Vector3Int(mouseGridPosition.x, mouseGridPosition.y, zPosition));
                }
                Event.current.Use();
                GUI.changed = true;
                break;

            case EventType.MouseDrag:
                executing = true;
                if (isHotControl && mouseGridPositionChanged)
                {
                    List <Vector2Int> points = GridEditorUtility.GetPointsOnLine(m_PreviousMouseGridPosition, mouseGridPosition).ToList();
                    if (points[0] == mouseGridPosition)
                    {
                        points.Reverse();
                    }

                    if (!evt.shift && !TilemapEditorTool.IsActive(typeof(PaintTool)) && m_TypeBeforeExecution == typeof(PaintTool))
                    {
                        TilemapEditorTool.SetActiveEditorTool(typeof(PaintTool));
                    }
                    else if (evt.shift && TilemapEditorTool.IsActive(typeof(PaintTool)))
                    {
                        TilemapEditorTool.SetActiveEditorTool(typeof(EraseTool));
                    }

                    for (int i = 1; i < points.Count; i++)
                    {
                        if (IsErasingEvent(evt))
                        {
                            Erase(new Vector3Int(points[i].x, points[i].y, zPosition));
                        }
                        else
                        {
                            Paint(new Vector3Int(points[i].x, points[i].y, zPosition));
                        }
                    }
                    Event.current.Use();
                    GUI.changed = true;
                }
                break;

            case EventType.MouseUp:
                executing = false;
                if (isHotControl)
                {
                    if (!TilemapEditorTool.IsActive(typeof(PaintTool)) && m_TypeBeforeExecution == typeof(PaintTool))
                    {
                        TilemapEditorTool.SetActiveEditorTool(typeof(PaintTool));
                    }

                    Event.current.Use();
                    GUI.changed           = true;
                    GUIUtility.hotControl = 0;
                }
                break;
            }
        }
コード例 #16
0
        private void DuringSceneGui(SceneView sceneView)
        {
            Event evt = Event.current;

            if (evt.type != EventType.DragUpdated && evt.type != EventType.DragPerform && evt.type != EventType.DragExited && evt.type != EventType.Repaint)
            {
                return;
            }

            Grid activeGrid = GetActiveGrid();

            if (activeGrid == null || DragAndDrop.objectReferences.Length == 0)
            {
                return;
            }

            Vector3    localMouse        = GridEditorUtility.ScreenToLocal(activeGrid.transform, evt.mousePosition);
            Vector3Int mouseGridPosition = activeGrid.LocalToCell(localMouse);

            switch (evt.type)
            {
            //TODO: Cache this
            case EventType.DragUpdated:
                DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                List <TileBase> tiles = TileDragAndDrop.GetValidTiles(DragAndDrop.objectReferences);
                instance.m_HoverData = TileDragAndDrop.CreateHoverData(null, null, tiles);
                if (instance.m_HoverData.Count > 0)
                {
                    Event.current.Use();
                    GUI.changed = true;
                }
                break;

            case EventType.DragPerform:
                if (instance.m_HoverData.Count > 0)
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                    var     tileSheet = TileDragAndDrop.ConvertToTileSheet(instance.m_HoverData);
                    Tilemap tilemap   = GetOrCreateActiveTilemap();
                    tilemap.ClearAllEditorPreviewTiles();
                    int i = 0;
                    foreach (KeyValuePair <Vector2Int, TileDragAndDropHoverData> item in instance.m_HoverData)
                    {
                        Vector3Int position = new Vector3Int(mouseGridPosition.x + item.Key.x, mouseGridPosition.y + item.Key.y, 0);
                        tilemap.SetTile(position, tileSheet[i++]);
                        tilemap.SetTransformMatrix(position, Matrix4x4.TRS(item.Value.positionOffset - tilemap.tileAnchor, Quaternion.identity, Vector3.one));
                    }
                    instance.m_HoverData = null;
                    GUI.changed          = true;
                    Event.current.Use();
                }
                break;

            case EventType.Repaint:
                if (instance.m_HoverData != null)
                {
                    Tilemap map = Selection.activeGameObject.GetComponentInParent <Tilemap>();

                    if (map != null)
                    {
                        map.ClearAllEditorPreviewTiles();
                    }

                    DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                    foreach (KeyValuePair <Vector2Int, TileDragAndDropHoverData> item in instance.m_HoverData)
                    {
                        Vector3Int gridPos = mouseGridPosition + new Vector3Int(item.Key.x, item.Key.y, 0);
                        if (item.Value.hoverObject is TileBase)
                        {
                            TileBase tile = item.Value.hoverObject as TileBase;
                            if (map != null)
                            {
                                map.SetEditorPreviewTile(gridPos, tile);
                            }
                        }
                    }
                }
                break;
            }

            if (instance.m_HoverData != null && (
                    Event.current.type == EventType.DragExited ||
                    Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape))
            {
                if (instance.m_HoverData.Count > 0)
                {
                    Tilemap map = Selection.activeGameObject.GetComponentInParent <Tilemap>();
                    if (map != null)
                    {
                        map.ClearAllEditorPreviewTiles();
                    }

                    Event.current.Use();
                }

                instance.m_HoverData = null;
            }
        }
コード例 #17
0
        private void HandleBrushPaintAndErase()
        {
            Event evt = Event.current;

            if (!IsPaintingEvent(evt) && !IsErasingEvent(evt))
            {
                return;
            }

            switch (evt.type)
            {
            case EventType.MouseDown:
                if (isNearestControl)
                {
                    RegisterUndo();
                    GUIUtility.hotControl = m_PermanentControlID;
                    executing             = true;
                    m_TypeBeforeExecution = EditorTools.ToolManager.activeToolType;
                    var position = new Vector3Int(mouseGridPosition.x, mouseGridPosition.y, zPosition);
                    if (IsErasingEvent(evt))
                    {
                        if (!TilemapEditorTool.IsActive(typeof(EraseTool)))
                        {
                            TilemapEditorTool.SetActiveEditorTool(typeof(EraseTool));
                        }
                        Erase(position);
                    }
                    else
                    {
                        if (!TilemapEditorTool.IsActive(typeof(PaintTool)))
                        {
                            TilemapEditorTool.SetActiveEditorTool(typeof(PaintTool));
                        }
                        Paint(position);
                    }
                    ResetPreviousMousePositionToCurrentPosition();
                    Event.current.Use();
                    GUI.changed = true;
                }
                break;

            case EventType.MouseDrag:
                executing = true;
                if (isHotControl && mouseGridPositionChanged)
                {
                    var points = GridEditorUtility.GetPointsOnLine(m_PreviousMouseGridPosition, mouseGridPosition);

                    if (!evt.shift && !TilemapEditorTool.IsActive(typeof(PaintTool)) && m_TypeBeforeExecution == typeof(PaintTool))
                    {
                        TilemapEditorTool.SetActiveEditorTool(typeof(PaintTool));
                    }
                    else if (evt.shift && TilemapEditorTool.IsActive(typeof(PaintTool)))
                    {
                        TilemapEditorTool.SetActiveEditorTool(typeof(EraseTool));
                    }

                    foreach (var point in points)
                    {
                        var position = new Vector3Int(point.x, point.y, zPosition);
                        if (IsErasingEvent(evt))
                        {
                            Erase(position);
                        }
                        else
                        {
                            Paint(position);
                        }
                    }
                    Event.current.Use();
                    GUI.changed = true;
                }
                break;

            case EventType.MouseUp:
                executing = false;
                if (isHotControl)
                {
                    if (!TilemapEditorTool.IsActive(typeof(PaintTool)) && m_TypeBeforeExecution == typeof(PaintTool))
                    {
                        TilemapEditorTool.SetActiveEditorTool(typeof(PaintTool));
                    }

                    Event.current.Use();
                    GUI.changed           = true;
                    GUIUtility.hotControl = 0;
                }
                break;
            }
        }