public static void OnSceneGUI(SceneView sceneView, Rect dragArea)
        {
            var editModes      = ChiselEditModeManager.editModes;
            var generatorModes = ChiselEditModeManager.generatorModes;

            if (editModeWindow == null)
            {
                var minWidth  = 80;
                var minHeight = 40;
                var rect      = new Rect(0, 0, 92, 24 + ((editModes.Length + generatorModes.Length) * (kSingleLineHeight + kSingleSpacing)) + kGeneratorSeparator + kExtraBottomSpacing);
                editModeWindow = new GUIResizableWindow("Tools", rect, minWidth, minHeight, OnWindowGUI);
            }

            editModeWindow.Show(dragArea);


            IChiselToolMode currentToolMode = ChiselEditModeManager.EditMode;

            if (currentToolMode != prevToolMode)
            {
                if (prevToolMode != null)
                {
                    prevToolMode.OnDisable();
                }

                // Set defaults
                ChiselOutlineRenderer.VisualizationMode = VisualizationMode.Outline;
                Tools.hidden = false;

                if (currentToolMode != null)
                {
                    currentToolMode.OnEnable();
                }
            }
            prevToolMode = currentToolMode;


            if (currentToolMode != null)
            {
                dragArea.x = 0;
                dragArea.y = 0;
                currentToolMode.OnSceneGUI(sceneView, dragArea);
            }
        }
        public static void OnSceneGUI(SceneView sceneView, Rect dragArea)
        {
            if (editModeWindow == null)
            {
                var minWidth  = 80;
                var minHeight = 40;
                var rect      = new Rect(0, 0, 92, 24 + ((editModes.Length + generatorModes.Length) * (kSingleLineHeight + kSingleSpacing)) + kGeneratorSeparator + kExtraBottomSpacing);
                editModeWindow = new GUIResizableWindow("Tools", rect, minWidth, minHeight, OnWindowGUI);
            }

            editModeWindow.Show(dragArea);


            ICSGToolMode currentToolMode = null;

            switch (CSGEditModeManager.EditMode)
            {
            // Edit modes
            case CSGEditMode.Object:                currentToolMode = ObjectEditMode;       break;

            case CSGEditMode.Pivot:                 currentToolMode = PivotEditMode;        break;

            case CSGEditMode.SurfaceEdit:   currentToolMode = SurfaceEditMode;      break;

            case CSGEditMode.ShapeEdit:             currentToolMode = ShapeEditMode;        break;

            // Generators
            case CSGEditMode.FreeDraw:              currentToolMode = ExtrudedShapeGeneratorMode; break;

            case CSGEditMode.RevolvedShape: currentToolMode = RevolvedShapeGeneratorMode; break;

            case CSGEditMode.Box:                   currentToolMode = BoxGeneratorMode; break;

            case CSGEditMode.Stadium:               currentToolMode = StadiumGeneratorMode; break;

            case CSGEditMode.Cylinder:              currentToolMode = CylinderGeneratorMode; break;

            case CSGEditMode.Hemisphere:    currentToolMode = HemisphereGeneratorMode; break;

            case CSGEditMode.Sphere:                currentToolMode = SphereGeneratorMode; break;

            case CSGEditMode.Capsule:               currentToolMode = CapsuleGeneratorMode; break;

            case CSGEditMode.Torus:                 currentToolMode = TorusGeneratorMode; break;

            case CSGEditMode.PathedStairs:  currentToolMode = PathedStairsGeneratorMode; break;

            case CSGEditMode.LinearStairs:  currentToolMode = LinearStairsGeneratorMode; break;

            case CSGEditMode.SpiralStairs:  currentToolMode = SpiralStairsGeneratorMode; break;
            }


            if (currentToolMode != prevToolMode)
            {
                if (prevToolMode != null)
                {
                    prevToolMode.OnDisable();
                }

                // Set defaults
                CSGOutlineRenderer.VisualizationMode = VisualizationMode.Outline;
                Tools.hidden = false;

                if (currentToolMode != null)
                {
                    currentToolMode.OnEnable();
                }
            }
            prevToolMode = currentToolMode;


            if (currentToolMode != null)
            {
                if (CSGEditModeManager.EditMode >= CSGEditMode.FirstGenerator)
                {
                    var evt = Event.current;
                    switch (evt.type)
                    {
                    case EventType.KeyDown:
                    case EventType.ValidateCommand:
                    {
                        if (Tools.current == Tool.View ||
                            Tools.current == Tool.None ||
                            (evt.modifiers & (EventModifiers.Shift | EventModifiers.Control | EventModifiers.Alt | EventModifiers.Command)) != EventModifiers.None ||
                            GUIUtility.hotControl != 0)
                        {
                            break;
                        }

                        if (evt.keyCode == KeyCode.Escape)
                        {
                            evt.Use();
                            break;
                        }
                        break;
                    }

                    case EventType.KeyUp:
                    {
                        if (Tools.current == Tool.View ||
                            Tools.current == Tool.None ||
                            (evt.modifiers & (EventModifiers.Shift | EventModifiers.Control | EventModifiers.Alt | EventModifiers.Command)) != EventModifiers.None ||
                            GUIUtility.hotControl != 0)
                        {
                            break;
                        }

                        if (evt.keyCode == KeyCode.Escape)
                        {
                            evt.Use();
                            Instance.RestoreSelection();
                            GUIUtility.ExitGUI();
                        }
                        break;
                    }
                    }
                }
                dragArea.x = 0;
                dragArea.y = 0;
                currentToolMode.OnSceneGUI(sceneView, dragArea);
            }
        }