private void OnSceneGUI()
    {
        Tools.current = Tool.None;

        if (Camera.current == null || editor.map == null)
        {
            return;
        }

        //This is needed to disable default object selection in scene
        int controlId = GUIUtility.GetControlID(FocusType.Passive);

        Event e = Event.current;

        if (e.type == EventType.MouseDown && e.button == 0 && e.modifiers == EventModifiers.None &&
            !sceneGUIRect.Contains(e.mousePosition))
        {
            editor.DrawWithBrush();
            GUIUtility.hotControl = controlId;
            e.Use();
        }

        if (e.type == EventType.MouseMove || e.type == EventType.MouseDrag)
        {
            Vector2 pos     = e.mousePosition;
            Ray     ray     = HandleUtility.GUIPointToWorldRay(pos);
            bool    changed = editor.SetCurrentMousePos(MapCellFromRay(ray));
            if (changed && e.type == EventType.MouseDrag && e.button == 0 && e.modifiers == EventModifiers.None)
            {
                editor.DrawWithBrush();
            }
        }

        if (e.type == EventType.KeyDown)
        {
            if (e.keyCode == KeyCode.Period)
            {
                editor.brushSize = Math.Min(9, editor.brushSize + 1);
                AfterHotkey(e);
            }
            else if (e.keyCode == KeyCode.Comma)
            {
                editor.brushSize = Math.Max(1, editor.brushSize - 1);
                AfterHotkey(e);
            }
            else if (e.keyCode == KeyCode.N)
            {
                editor.brushMode = MapEditor.BrushMode.Excavate;
                AfterHotkey(e);
            }
            else if (e.keyCode == KeyCode.M)
            {
                editor.brushMode = MapEditor.BrushMode.Fill;
                AfterHotkey(e);
            }
        }

        RenderSceneUI();
    }