static void ValidateDrop(bool inSceneView, Transform transformInInspector)
 {
     if (currentDragTool != null)
     {
         currentDragTool.Reset();
     }
     currentDragTool             = null;
     currentDragToolActive       = false;
     currentTransformInInspector = transformInInspector;
     if (materialDragTool.ValidateDrop(inSceneView))
     {
         currentDragTool = materialDragTool;
     }
     else
     if (brushDragTool.ValidateDrop(inSceneView))
     {
         currentDragTool = brushDragTool;
     }
     else
     if (meshDragTool.ValidateDrop(inSceneView))
     {
         currentDragTool = meshDragTool;
     }
 }
        internal static void UpdateDragAndDrop()
        {
            // TODO: never use drag & drop code when dropping into inspector
            //			instead:
            //			find 'new' components, check if they're part of a prefab,
            //			check if that prefab has a copy flag, and replace it with a copy


            if (currentTransformInInspector)
            {
                if (currentDragTool != null)
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
                    if (currentDragToolActive)
                    {
                        currentDragTool.Reset();
                    }
                    currentDragTool             = null;
                    currentTransformInInspector = null;
                    draggingInScene             = false;
                }
                currentTransformInInspector = null;
            }
        }
        internal static void OnHandleDragAndDrop(bool inSceneView, Transform transformInInspector = null, Rect?selectionRect = null)
        {
            switch (Event.current.type)
            {
            case EventType.DragUpdated:
            {
                if (!draggingInScene)
                {
                    ValidateDrop(inSceneView, transformInInspector);
                }

                if (currentDragTool != null)
                {
                    if (!currentDragTool.ValidateDropPoint(inSceneView))
                    {
                        if (currentDragTool != null && currentDragToolActive)
                        {
                            currentDragTool.DragExited(inSceneView);
                        }
                        currentDragToolActive = false;
                    }
                    else
                    {
                        currentDragToolActive   = true;
                        IsDraggingObjectInScene = true;
                        DragAndDrop.visualMode  = DragAndDropVisualMode.Generic;
                        if (inSceneView)
                        {
                            if (currentDragTool.DragUpdated())
                            {
                                HandleUtility.Repaint();
                            }
                        }
                        else
                        {
                            if (currentDragTool.DragUpdated(transformInInspector, selectionRect.Value))
                            {
                                CSG_EditorGUIUtility.RepaintAll();
                            }
                        }
                        Event.current.Use();
                        draggingInScene = true;
                    }
                }
                break;
            }

            case EventType.DragPerform:
            {
                if (currentDragTool != null)
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
                    if (currentDragToolActive)
                    {
                        currentDragTool.DragPerform(inSceneView);
                        currentDragTool.Reset();
                        Event.current.Use();
                    }
                    currentDragTool             = null;
                    currentTransformInInspector = null;
                    draggingInScene             = false;
                }
                break;
            }

            case EventType.DragExited:
                //case EventType.MouseMove:
            {
                if (currentDragTool != null)
                {
                    currentDragTool.DragExited(inSceneView);
                    Event.current.Use();
                    IsDraggingObjectInScene     = false;
                    currentDragTool             = null;
                    currentTransformInInspector = null;
                    draggingInScene             = false;
                    CSG_EditorGUIUtility.RepaintAll();
                }
                break;
            }
            }
        }