public override void OnInspectorGUI()
        {
            serializedObject.Update();

            if (levelEditor == null)
            {
                levelEditor = ((LevelEditor)target);
            }

            var groundBrush = serializedObject.FindProperty("GroundBrush");
            var propBrush   = serializedObject.FindProperty("Props");
            var snapOption  = serializedObject.FindProperty("Snapping");

            DrawProperty(groundBrush, "Ground Set", levelEditor.GroundBrush != null ? levelEditor.GroundBrush.Count : 0, DropGroundBrushAction, DrawGroundBrush);
            DrawProperty(propBrush, "Props Set", levelEditor.Props != null ? levelEditor.Props.Count : 0, DropPropsBrushAction, DrawPropsBrush);
            EditorGUILayout.PropertyField(snapOption);

            serializedObject.ApplyModifiedProperties();
            EditorUtility.SetDirty(target);
        }
        private void OnSceneGUI()
        {
            if (levelEditor == null)
            {
                levelEditor = (LevelEditor)target;
            }

            Event e = Event.current;

            if (e.type == EventType.KeyDown)
            {
                if (e.shift && e.keyCode == KeyCode.S)
                {
                    // Toggle Level Editor on SHIFT + S
                    levelEditor.on = !levelEditor.on;
                    if (!levelEditor.on)
                    {
                        isScaling  = false;
                        isRotating = false;
                    }
                }
                else if (e.shift && e.keyCode == KeyCode.Q)
                {
                    levelEditor.ChangeBrush(LEChangeBrushDirection.LEFT);
                }
                else if (e.shift && e.keyCode == KeyCode.E)
                {
                    levelEditor.ChangeBrush(LEChangeBrushDirection.RIGHT);
                }
                else if (e.shift && e.keyCode == KeyCode.R && levelEditor.on)
                {
                    isScaling = !isScaling;
                    if (!isScaling)
                    {
                        isRotating = false;
                    }
                }
                else if (e.shift && e.keyCode == KeyCode.T && levelEditor.on)
                {
                    isRotating = !isRotating;
                    if (!isRotating)
                    {
                        isScaling = false;
                    }
                }
            }

            if (e.type == EventType.KeyUp && e.control && e.keyCode == KeyCode.Z && levelEditor.on)
            {
                levelEditor.ResetBrushTransform();
            }

            if (isScaling)
            {
                EditorGUI.BeginChangeCheck();

                float   handleSize = HandleUtility.GetHandleSize(levelEditor.BrushTransform().position);
                Vector3 newScale   = Handles.ScaleHandle(
                    levelEditor.BrushTransform().localScale,
                    levelEditor.BrushTransform().position,
                    levelEditor.BrushTransform().rotation, handleSize);

                if (EditorGUI.EndChangeCheck())
                {
                    levelEditor.ScaleCurrentBrush(newScale);
                }
            }

            if (isRotating)
            {
                EditorGUI.BeginChangeCheck();
                Quaternion newRotation = Handles.RotationHandle(
                    levelEditor.BrushTransform().rotation,
                    levelEditor.BrushTransform().localPosition);

                if (EditorGUI.EndChangeCheck())
                {
                    levelEditor.RotateCurrentBrush(newRotation);
                }
            }

            GUILayout.BeginArea(new Rect(20, 20, 190, 270));
            {
                var rect = EditorGUILayout.BeginVertical();
                {
                    GUI.Box(rect, GUIContent.none);

                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.FlexibleSpace();
                        GUIStyle myLabelStyle = new GUIStyle(GUI.skin.label);
                        myLabelStyle.normal.textColor = Color.black;
                        myLabelStyle.fontSize         = 12;

                        GUILayout.Label("Level Editor", myLabelStyle);

                        GUILayout.FlexibleSpace();
                    }
                    GUILayout.EndHorizontal();

                    GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));

                    GUILayout.BeginHorizontal();
                    {
                        GUIStyle statusStyle = new GUIStyle(EditorStyles.boldLabel);

                        if (levelEditor.on)
                        {
                            GUILayout.Label("Current Status: ACTIVE \n(SHIFT + S to deactivate)", statusStyle);
                        }
                        else
                        {
                            GUILayout.Label("Current Status: INNACTIVE \n(SHIFT + S to activate)");
                        }
                    }
                    GUILayout.EndHorizontal();


                    GUILayout.BeginVertical();
                    {
                        GUIStyle selectedSet = new GUIStyle(EditorStyles.boldLabel);
                        if (levelEditor.eSelectedBrush == LESelectedBrush.GROUND)
                        {
                            GUILayout.BeginHorizontal();
                            GUILayout.Label("Current Set: ");
                            GUILayout.Label("GROUND", selectedSet);
                            GUILayout.EndHorizontal();
                        }
                        else
                        {
                            GUILayout.BeginHorizontal();
                            GUILayout.Label("Current Set: ");
                            GUILayout.Label("PROPS", selectedSet);
                            GUILayout.EndHorizontal();
                        }

                        GUILayout.Label("(Shift + W to change set)");

                        if (levelEditor.GroundBrush.Count > 0)
                        {
                            GameObject obj     = levelEditor.GroundBrush[levelEditor.selectedGround];
                            Texture2D  preview = AssetPreview.GetAssetPreview(obj);

                            GUILayout.BeginHorizontal();
                            {
                                GUILayout.FlexibleSpace();

                                GUILayout.Label("Selected Brush: ", new GUIStyle(EditorStyles.boldLabel));
                                GUILayout.FlexibleSpace();
                            }
                            GUILayout.EndHorizontal();
                            GUILayout.BeginHorizontal();
                            {
                                if (GUILayout.Button("<"))
                                {
                                    levelEditor.ChangeBrush(LEChangeBrushDirection.LEFT);
                                }

                                GUILayout.FlexibleSpace();
                                GUILayout.Label(preview);
                                GUILayout.FlexibleSpace();

                                if (GUILayout.Button(">"))
                                {
                                    levelEditor.ChangeBrush(LEChangeBrushDirection.RIGHT);
                                }
                            }
                            GUILayout.EndHorizontal();

                            GUILayout.BeginHorizontal();
                            GUILayout.Label("To change Brush press \nSHIFT-Q or SHIFT-E");
                            GUILayout.EndHorizontal();
                        }
                    }
                    GUILayout.EndVertical();
                }
                EditorGUILayout.EndVertical();
            }
            GUILayout.EndArea();

            if (levelEditor.on && !isScaling && !isRotating)
            {
                // Way of controlling the drag-click-move
                //
                //int controlId = GUIUtility.GetControlID(FocusType.Passive);
                //GUIUtility.hotControl = controlId;
                //HandleUtility.AddDefaultControl(GUIUtility.GetControlID(GetHashCode(), FocusType.Passive));
                //Event.current.Use();
                int controlId = GUIUtility.GetControlID(FocusType.Passive);

                switch (Event.current.type)
                {
                case EventType.MouseDown:
                    OnMouseDown(Event.current);
                    break;

                case EventType.MouseMove:
                    OnMouseMove(Event.current);
                    break;

                case EventType.MouseDrag:
                    GUIUtility.hotControl = controlId;
                    OnMouseDrag(Event.current);
                    Event.current.Use();
                    break;

                default:
                    HandleUtility.AddDefaultControl(GUIUtility.GetControlID(GetHashCode(), FocusType.Passive));
                    break;
                }
            }
        }