UnityEditor extension is one-line-drag (drag-drag-drop) area _Undo_DisableGroup, etc.

drag area

   var are = GUILayoutUtility.GetRect(0f, 100f, GUILayout.ExpandWidth(true));
        GUI.contentColor = Color.white;
        GUI.Box(are, "\n拖拽区域");
        EditorGUILayout.Space();
        var eventType = Event.current.type;
        switch (eventType)
        {
            case EventType.DragUpdated:
            case EventType.DragPerform:
                if (are.Contains(Event.current.mousePosition))
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                    if (eventType == EventType.DragPerform)
                    {
                        DragAndDrop.AcceptDrag();
                        for (int i = 0; i < DragAndDrop.objectReferences.Length; ++i)
                        {
                            if (i >= 1)
                            {
                                Debug.LogError("拖拽超过一个,只取第一个");
                                continue;
                                
                            }

                            var o = DragAndDrop.objectReferences[i];
                            Debug.LogWarning("拖了一个??" + o.GetType());
                        }
                    }
                    Event.current.Use();
                }

                break;
            default:
                break;
        }

The final effect is good

 

DisableButtonGroup

I've always wanted a button that can't be pressed, and found that the Editor's button (gui) doesn't have a disable option, and now I know it today

People (gui) have DisableButtonGroup

Guess you like

Origin blog.csdn.net/avi9111/article/details/122487223