Example #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;
            var plusIconContext = EditorGUIUtility.IconContent("Toolbar Plus");

            if (GUI.Button(labelRect, plusIconContext, GUIStyle.none))
            {
                OpenAddMenu(property);
            }

            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_TreeView.OnGUI(treeRect);

            if (m_TreeView.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();
        }