示例#1
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, label, property);

            SetActionNameIfNotSet(property);

            var labelRect = position;

            EditorGUI.LabelField(labelRect, GUIContent.none, Styles.actionTreeBackground);
            var headerRect = new Rect(labelRect.x + 1, labelRect.y + 1, labelRect.width - 2, labelRect.height - 2);

            EditorGUI.LabelField(headerRect, label, Styles.columnHeaderLabel);

            labelRect.x     = labelRect.width - (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing);
            labelRect.width = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            if (GUI.Button(labelRect, m_PlusIconContext, GUIStyle.none))
            {
                OpenAddMenu(property);
            }

            labelRect.x += labelRect.width;
            if (GUI.Button(labelRect, m_MinusIconContext, GUIStyle.none))
            {
                EditorWindow.focusedWindow.SendEvent(EditorGUIUtility.CommandEvent("Delete"));
            }

            InitTreeIfNeeded(property);

            position.y += Styles.columnHeaderLabel.fixedHeight;
            var treeRect = new Rect(position.x + 1, position.y + 1,
                                    position.width - 2, position.height - Styles.columnHeaderLabel.fixedHeight - 2);

            m_Tree.OnGUI(treeRect);

            if (m_Tree.HasFocus())
            {
                if (Event.current.type == EventType.ValidateCommand)
                {
                    if (CopyPasteUtility.IsValidCommand(Event.current.commandName))
                    {
                        Event.current.Use();
                    }
                }

                if (Event.current.type == EventType.ExecuteCommand)
                {
                    m_CopyPasteUtility.HandleCommandEvent(Event.current.commandName);
                }
            }

            EditorGUI.EndProperty();
        }