private void OnGUI()
        {
            if (Event.current.type == EventType.KeyDown)
            {
                if (m_ActionMapsTree.HasFocus() && Event.current.keyCode == KeyCode.RightArrow)
                {
                    if (!m_ActionsTree.HasSelection())
                    {
                        m_ActionsTree.SelectFirstRow();
                    }
                    m_ActionsTree.SetFocus();
                }
            }

            EditorGUILayout.BeginVertical();
            m_InputActionWindowToolbar.OnGUI();
            EditorGUILayout.Space();

            var isPickingInteractively = m_BindingPropertyView != null && m_BindingPropertyView.isInteractivelyPicking;

            EditorGUI.BeginDisabledGroup(isPickingInteractively);

            // Draw columns.
            var columnsRect     = EditorGUILayout.BeginHorizontal();
            var columnAreaWidth = position.width - Styles.actionTreeBackground.margin.left - Styles.actionTreeBackground.margin.left - Styles.propertiesBackground.margin.right;

            DrawActionMapsColumn(columnAreaWidth * 0.22f);
            DrawActionsColumn(columnAreaWidth * 0.38f);
            DrawPropertiesColumn(columnAreaWidth * 0.40f);
            EditorGUILayout.EndHorizontal();

            // If we're currently interactively picking a binding, aside from disabling and dimming the normal UI, display a large text over
            // the window that says we're waiting for input.
            // NOTE: We're not using EditorWindow.ShowNotification() as, aside from having trouble displaying our dynamically generated text
            //       properly without clipping, notifications will automatically disappear after a brief moment. We want the input requester
            //       to stay visible for as long as we're still looking for input.
            EditorGUI.EndDisabledGroup();
            if (isPickingInteractively)
            {
                DrawInteractivePickingOverlay(columnsRect);
            }

            // Bottom margin.
            GUILayout.Space(3);
            EditorGUILayout.EndVertical();

            if (Event.current.type == EventType.ValidateCommand)
            {
                if (InputActionCopyPasteUtility.IsValidCommand(Event.current.commandName))
                {
                    Event.current.Use();
                }
            }
            if (Event.current.type == EventType.ExecuteCommand)
            {
                m_CopyPasteUtility.HandleCommandEvent(Event.current.commandName);
            }
        }
Пример #2
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_PlusIconContent, GUIStyle.none))
            {
                OpenAddMenu(property);
            }

            labelRect.x += labelRect.width;
            if (GUI.Button(labelRect, m_MinusIconContent, 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 (InputActionCopyPasteUtility.IsValidCommand(Event.current.commandName))
                    {
                        Event.current.Use();
                    }
                }
                else if (Event.current.type == EventType.ExecuteCommand)
                {
                    m_CopyPasteUtility.HandleCommandEvent(Event.current.commandName);
                }
            }

            EditorGUI.EndProperty();
        }