Ejemplo n.º 1
0
        private void OnItemDoubleClicked(ActionTreeItemBase item)
        {
            // Double-clicking on binding or action item opens property popup.
            PropertiesViewBase propertyView = null;

            if (item is BindingTreeItem)
            {
                if (m_ControlPickerState == null)
                {
                    m_ControlPickerState = new InputControlPickerState();
                }
                propertyView = new InputBindingPropertiesView(item.property,
                                                              controlPickerState: m_ControlPickerState,
                                                              expectedControlLayout: item.expectedControlLayout,
                                                              onChange:
                                                              change => m_TreeView.Reload());
            }
            else if (item is ActionTreeItem)
            {
                propertyView = new InputActionPropertiesView(item.property,
                                                             onChange: change => m_TreeView.Reload());
            }

            if (propertyView != null)
            {
                var rect = new Rect(GUIUtility.GUIToScreenPoint(Event.current.mousePosition), Vector2.zero);
                PropertiesViewPopup.Show(rect, propertyView);
            }
        }
Ejemplo n.º 2
0
        private void LoadPropertiesForSelection()
        {
            m_BindingPropertyView = null;
            m_ActionPropertyView  = null;

            // Column #1: Load selected action map.
            if (m_ActionMapsTree.GetSelectedRow() != null)
            {
                var row = m_ActionMapsTree.GetSelectedRow();
                if (row != null)
                {
                    m_ActionsTree.actionMapProperty = m_ActionMapsTree.GetSelectedRow().elementProperty;
                    m_ActionsTree.Reload();
                }
            }

            // Column #2: Load selected action or binding.
            if (m_ActionsTree.HasSelection() && m_ActionsTree.GetSelection().Count == 1)
            {
                var item = m_ActionsTree.GetSelectedRow();
                if (item is BindingTreeItem)
                {
                    // Grab the action for the binding and see if we have an expected control layout
                    // set on it. Pass that on to the control picking machinery.
                    var isCompositeTreeItem = item is CompositeTreeItem;
                    var actionItem          = (isCompositeTreeItem ? item.parent.parent : item.parent) as ActionTreeItem;
                    Debug.Assert(actionItem != null);

                    // Show properties for binding.
                    m_BindingPropertyView =
                        new InputBindingPropertiesView(
                            item.elementProperty,
                            change =>
                    {
                        Apply();
                    },
                            m_PickerTreeViewState,
                            m_InputActionWindowToolbar,
                            item.expectedControlLayout);

                    // For composite groups, don't show the binding path and control scheme section,
                    // but show composite parameters instead.
                    if (item is CompositeGroupTreeItem)
                    {
                        m_BindingPropertyView.isCompositeBinding = true;
                    }
                }
                if (item is ActionTreeItem)
                {
                    var actionItem = item as ActionTreeItem;
                    Debug.Assert(actionItem != null);

                    // Show properties for binding.
                    m_ActionPropertyView =
                        new InputActionPropertiesView(
                            item.elementProperty,
                            Apply);
                }
            }
        }
        private void LoadPropertiesForSelection()
        {
            m_BindingPropertyView = null;
            m_ActionPropertyView  = null;

            ////TODO: preserve interaction/processor selection when reloading

            // Nothing else to do if we don't have a selection in the middle pane or if
            // multiple items are selected (we don't currently have the ability to multi-edit).
            if (!m_ActionsTree.HasSelection() || m_ActionsTree.GetSelection().Count != 1)
            {
                return;
            }

            var item = m_ActionsTree.GetSelectedItems().FirstOrDefault();

            if (item is BindingTreeItem)
            {
                // Grab the action for the binding and see if we have an expected control layout
                // set on it. Pass that on to the control picking machinery.
                var isCompositePartBinding = item is PartOfCompositeBindingTreeItem;
                var isCompositeBinding     = item is CompositeBindingTreeItem;
                var actionItem             = (isCompositePartBinding ? item.parent.parent : item.parent) as ActionTreeItem;
                Debug.Assert(actionItem != null);

                if (m_ControlPickerViewState == null)
                {
                    m_ControlPickerViewState = new InputControlPickerState();
                }

                // The toolbar may constrain the set of devices we're currently interested in by either
                // having one specific device selected from the current scheme or having at least a control
                // scheme selected.
                var controlPathsToMatch = (IEnumerable <string>)null;
                if (m_Toolbar.selectedDeviceRequirement != null)
                {
                    // Single device selected from set of devices in control scheme.
                    controlPathsToMatch = new[] { m_Toolbar.selectedDeviceRequirement.Value.controlPath };
                }
                else if (m_Toolbar.selectedControlScheme != null)
                {
                    // Constrain to devices from current control scheme.
                    controlPathsToMatch =
                        m_Toolbar.selectedControlScheme.Value.deviceRequirements.Select(x => x.controlPath);
                }
                else
                {
                    // If there's no device filter coming from a control scheme, filter by supported
                    // devices as given by settings.
                    controlPathsToMatch = InputSystem.settings.supportedDevices;
                }

                // Show properties for binding.
                m_BindingPropertyView =
                    new InputBindingPropertiesView(
                        item.property,
                        change =>
                {
                    if (change == InputBindingPropertiesView.k_PathChanged ||
                        change == InputBindingPropertiesView.k_CompositePartAssignmentChanged ||
                        change == InputBindingPropertiesView.k_CompositeTypeChanged)
                    {
                        ApplyAndReloadTrees();
                    }
                    else
                    {
                        // Simple property change that doesn't affect the rest of the UI.
                        Apply();
                    }
                },
                        m_ControlPickerViewState,
                        expectedControlLayout: item.expectedControlLayout,
                        controlSchemes: m_Toolbar.controlSchemes,
                        controlPathsToMatch: controlPathsToMatch);
            }
            else if (item is ActionTreeItem actionItem)
            {
                // Show properties for action.
                m_ActionPropertyView =
                    new InputActionPropertiesView(
                        actionItem.property,
                        // Apply without reload is enough here as modifying the properties of an action will
                        // never change the structure of the data.
                        change => Apply());
            }
        }
        private void LoadPropertiesForSelection()
        {
            m_BindingPropertyView = null;
            m_ActionPropertyView  = null;

            // Column #1: Load selected action map.
            if (m_ActionMapsTree.GetSelectedRow() != null)
            {
                var row = m_ActionMapsTree.GetSelectedRow();
                if (row != null)
                {
                    m_ActionsTree.actionMapProperty = m_ActionMapsTree.GetSelectedRow().elementProperty;
                    m_ActionsTree.Reload();
                }
            }

            // Column #2: Load selected action or binding.
            if (m_ActionsTree.HasSelection() && m_ActionsTree.GetSelection().Count == 1)
            {
                var item = m_ActionsTree.GetSelectedRow();
                if (item is BindingTreeItem)
                {
                    // Grab the action for the binding and see if we have an expected control layout
                    // set on it. Pass that on to the control picking machinery.
                    var isCompositePartBinding = item is CompositeTreeItem;
                    var isCompositeBinding     = item is CompositeGroupTreeItem;
                    var actionItem             = (isCompositePartBinding ? item.parent.parent : item.parent) as ActionTreeItem;
                    Debug.Assert(actionItem != null);

                    // Show properties for binding.
                    m_BindingPropertyView =
                        new InputBindingPropertiesView(
                            item.elementProperty,
                            change =>
                    {
                        if (change == InputBindingPropertiesView.k_CompositeTypeChanged)
                        {
                            Debug.Assert(isCompositeBinding, "Binding is expected to be a composite");

                            // This is a pretty complex change. We basically tear out part of the binding tree
                            // and replace it with a different structure.
                            var actionMapRow = (ActionMapTreeItem)m_ActionMapsTree.GetSelectedRow();
                            Debug.Assert(actionMapRow != null);

                            var compositeName = m_BindingPropertyView.compositeType;
                            var compositeType = InputBindingComposite.s_Composites.LookupTypeRegistration(compositeName);

                            InputActionSerializationHelpers.ChangeCompositeType(actionMapRow.bindingsProperty,
                                                                                actionItem.bindingsStartIndex + item.index, compositeName, compositeType,
                                                                                actionItem.actionName);

                            ApplyAndReload();
                        }
                        else if (change == InputBindingPropertiesView.k_PathChanged)
                        {
                            // If path changed, perform a full reload as it affects the action tree.
                            // Otherwise just do a "soft" apply. This is important so as to not lose
                            // edit state while editing parameters on interactions or processors.
                            ApplyAndReload();
                        }
                        else
                        {
                            // Simple property change that doesn't affect the rest of the UI.
                            Apply();
                        }
                    },
                            m_PickerTreeViewState,
                            m_InputActionWindowToolbar,
                            isCompositeBinding: isCompositeBinding,
                            expectedControlLayout: item.expectedControlLayout);
                }

                if (item is ActionTreeItem actionItem1)
                {
                    // Show properties for binding.
                    m_ActionPropertyView =
                        new InputActionPropertiesView(
                            actionItem1.elementProperty,
                            // Apply without reload is enough here.
                            change => Apply());
                }
            }
        }