public override bool GetDropLocation(Type itemType, int?childIndex, ref SerializedProperty array, ref int arrayIndex)
        {
            // Drop bindings into binding array.
            if (typeof(BindingTreeItem).IsAssignableFrom(itemType))
            {
                array = bindingsArrayProperty;

                // Indexing by tree items is relative to each action but indexing in
                // binding array is global for all actions in a map. Adjust index accordingly.
                // NOTE: Bindings for any one action need not be stored contiguously in the binding array
                //       so we can't just add something to the index of the first binding to the action.
                arrayIndex =
                    InputActionSerializationHelpers.ConvertBindingIndexOnActionToBindingIndexInArray(
                        array, name, childIndex ?? -1);

                return(true);
            }

            // Drop other actions next to us.
            if (itemType == typeof(ActionTreeItem))
            {
                array      = arrayProperty;
                arrayIndex = this.arrayIndex + 1;
                return(true);
            }

            return(false);
        }
Ejemplo n.º 2
0
        void DeleteSelectedRows(SerializedProperty actionProperty)
        {
            var row     = m_TreeView.GetSelectedRow();
            var rowType = row.GetType();

            // Remove composite bindings
            if (rowType == typeof(CompositeTreeItem))
            {
                for (var i = row.children.Count - 1; i >= 0; i--)
                {
                    var composite = (CompositeTreeItem)row.children[i];

                    InputActionSerializationHelpers.RemoveBinding(actionProperty, composite.index);
                }
                InputActionSerializationHelpers.RemoveBinding(actionProperty, row.index);
            }

            // Remove bindings
            if (rowType == typeof(BindingTreeItem))
            {
                InputActionSerializationHelpers.RemoveBinding(actionProperty, row.index);
            }

            m_TreeView.SetSelection(new List <int>());
            m_TreeView.Reload();
        }
Ejemplo n.º 3
0
        void OnAddAction()
        {
            var actionLine = GetSelectedActionMapLine();

            InputActionSerializationHelpers.AddAction(actionLine.elementProperty);
            Apply();
        }
Ejemplo n.º 4
0
        protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
        {
            if (args.dragAndDropPosition != DragAndDropPosition.BetweenItems)
            {
                return(DragAndDropVisualMode.None);
            }

            var id   = Int32.Parse(DragAndDrop.paths.First());
            var item = FindItem(id, rootItem);
            var row  = (ActionMapTreeItem)item;

            if (!row.isDraggable || args.parentItem != row.parent)
            {
                return(DragAndDropVisualMode.None);
            }

            if (args.performDrop)
            {
                var dstIndex = args.insertAtIndex;
                var srcIndex = row.index;

                if (dstIndex > srcIndex)
                {
                    dstIndex--;
                }

                InputActionSerializationHelpers.MoveActionMap(m_SerializedObject, srcIndex, dstIndex);
                m_ApplyAction();
                DragAndDrop.AcceptDrag();
            }
            return(DragAndDropVisualMode.Move);
        }
Ejemplo n.º 5
0
        private void ParseBindings(TreeViewItem parent, string actionMapName, string actionName, SerializedProperty bindingsArrayProperty, int depth)
        {
            var bindingsCount = InputActionSerializationHelpers.GetBindingCount(bindingsArrayProperty, actionName);
            CompositeGroupTreeItem compositeGroupTreeItem = null;

            for (var j = 0; j < bindingsCount; j++)
            {
                var bindingProperty = InputActionSerializationHelpers.GetBinding(bindingsArrayProperty, actionName, j);
                var bindingsItem    = new BindingTreeItem(actionMapName, bindingProperty, j);
                bindingsItem.depth = depth;
                if (bindingsItem.isComposite)
                {
                    compositeGroupTreeItem       = new CompositeGroupTreeItem(actionMapName, bindingProperty, j);
                    compositeGroupTreeItem.depth = depth;
                    parent.AddChild(compositeGroupTreeItem);
                    continue;
                }
                if (bindingsItem.isPartOfComposite)
                {
                    var compositeItem = new CompositeTreeItem(actionMapName, bindingProperty, j);
                    compositeItem.depth = depth + 1;
                    if (compositeGroupTreeItem != null)
                    {
                        compositeGroupTreeItem.AddChild(compositeItem);
                    }
                    continue;
                }
                compositeGroupTreeItem = null;
                parent.AddChild(bindingsItem);
            }
        }
Ejemplo n.º 6
0
        public InputBindingPropertiesView(
            SerializedProperty bindingProperty,
            Action <FourCC> onChange = null,
            InputControlPickerState controlPickerState = null,
            string expectedControlLayout = null,
            ReadOnlyArray <InputControlScheme> controlSchemes = new ReadOnlyArray <InputControlScheme>(),
            IEnumerable <string> controlPathsToMatch          = null)
            : base(InputActionSerializationHelpers.IsCompositeBinding(bindingProperty) ? "Composite" : "Binding",
                   bindingProperty, onChange, expectedControlLayout)
        {
            m_BindingProperty       = bindingProperty;
            m_GroupsProperty        = bindingProperty.FindPropertyRelative("m_Groups");
            m_PathProperty          = bindingProperty.FindPropertyRelative("m_Path");
            m_BindingGroups         = m_GroupsProperty.stringValue.Split(InputBinding.kSeparator).ToList();
            m_ExpectedControlLayout = expectedControlLayout;
            m_ControlSchemes        = controlSchemes;

            var flags = (InputBinding.Flags)bindingProperty.FindPropertyRelative("m_Flags").intValue;

            m_IsPartOfComposite = (flags & InputBinding.Flags.PartOfComposite) != 0;
            m_IsComposite       = (flags & InputBinding.Flags.Composite) != 0;

            // Set up control picker for m_Path. Not needed if the binding is a composite.
            if (!m_IsComposite)
            {
                m_ControlPickerState = controlPickerState ?? new InputControlPickerState();
                m_ControlPathEditor  = new InputControlPathEditor(m_PathProperty, m_ControlPickerState, OnPathChanged);
                m_ControlPathEditor.SetExpectedControlLayout(m_ExpectedControlLayout);
                if (controlPathsToMatch != null)
                {
                    m_ControlPathEditor.SetControlPathsToMatch(controlPathsToMatch);
                }
            }
        }
        public override bool GetDropLocation(Type itemType, int?childIndex, ref SerializedProperty array, ref int arrayIndex)
        {
            // Drop part binding into composite.
            if (itemType == typeof(PartOfCompositeBindingTreeItem))
            {
                array = arrayProperty;

                // Adjust child index by index of composite item itself.
                arrayIndex = childIndex != null
                    ? this.arrayIndex + 1 + childIndex.Value // Dropping at #0 should put as our index plus one.
                    : this.arrayIndex + 1 + InputActionSerializationHelpers.GetCompositePartCount(array, this.arrayIndex);

                return(true);
            }

            // Drop other bindings next to us.
            if (typeof(BindingTreeItem).IsAssignableFrom(itemType))
            {
                array      = arrayProperty;
                arrayIndex = this.arrayIndex + 1 +
                             InputActionSerializationHelpers.GetCompositePartCount(array, this.arrayIndex);
                return(true);
            }

            return(false);
        }
Ejemplo n.º 8
0
        void OnAddBinding()
        {
            var actionMapLine = GetSelectedActionMapLine();
            var actionLine    = GetSelectedActionLine();

            InputActionSerializationHelpers.AppendBinding(actionLine.elementProperty, actionMapLine.elementProperty);
            Apply();
        }
Ejemplo n.º 9
0
        protected void AddAction(object propertyObj)
        {
            var property = (SerializedProperty)propertyObj;

            InputActionSerializationHelpers.AddAction(property);
            property.serializedObject.ApplyModifiedProperties();
            m_TreeView.Reload();
        }
Ejemplo n.º 10
0
        void OnAddCompositeBinding(object dimensionNumber)
        {
            var actionMapLine = GetSelectedActionMapLine();
            var actionLine    = GetSelectedActionLine();

            InputActionSerializationHelpers.AppendCompositeBinding(actionLine.elementProperty, actionMapLine.elementProperty, (int)dimensionNumber);
            Apply();
        }
Ejemplo n.º 11
0
        internal void AddBinding(object propertyObj)
        {
            var property = (SerializedProperty)propertyObj;

            InputActionSerializationHelpers.AddBinding(property, null);
            property.serializedObject.ApplyModifiedProperties();
            m_Tree.Reload();
        }
 public object this[int index]
 {
     get
     {
         return(InputActionSerializationHelpers.GetBinding(m_BindingArrayProperty, m_ActionName, index));
     }
     set { throw new NotSupportedException(); }
 }
Ejemplo n.º 13
0
        private void DeleteSelectedRows()
        {
            var rows     = m_TreeView.GetSelectedRows().ToArray();
            var rowTypes = rows.Select(r => r.GetType()).Distinct().ToList();

            // Don't allow to delete different types at once because it's hard to handle.
            if (rowTypes.Count() > 1)
            {
                EditorApplication.Beep();
                return;
            }

            // Remove composite bindings
            foreach (var compositeGroup in FindRowsToDeleteOfType <CompositeGroupTreeItem>(rows))
            {
                var action = (compositeGroup.parent as ActionTreeItem);
                for (var i = compositeGroup.children.Count - 1; i >= 0; i--)
                {
                    var composite = (CompositeTreeItem)compositeGroup.children[i];
                    action.RemoveBinding(composite.index);
                }
                action.RemoveBinding(compositeGroup.index);
            }

            // Remove bindings
            foreach (var bindingRow in FindRowsToDeleteOfType <BindingTreeItem>(rows))
            {
                var action = bindingRow.parent as ActionTreeItem;
                action.RemoveBinding(bindingRow.index);
            }

            // Remove actions
            foreach (var actionRow in FindRowsToDeleteOfType <ActionTreeItem>(rows))
            {
                var action    = actionRow;
                var actionMap = actionRow.parent as ActionMapTreeItem;

                var bindingsCount = InputActionSerializationHelpers.GetBindingCount(actionMap.bindingsProperty, action.actionName);
                for (var i = bindingsCount - 1; i >= 0; i--)
                {
                    action.RemoveBinding(i);
                }
                actionMap.DeleteAction(actionRow.index);
            }

            //Remove action maps
            foreach (var mapRow in FindRowsToDeleteOfType <ActionMapTreeItem>(rows))
            {
                if (m_SerializedObject == null)
                {
                    throw new InvalidOperationException("Deleting action map is not a valid operation");
                }
                InputActionSerializationHelpers.DeleteActionMap(m_SerializedObject, mapRow.index);
            }

            m_TreeView.SetSelection(new List <int>());
            m_Apply();
        }
        void ParseActionMap(ActionMapTreeItem actionMapItem, InputActionMap actionMap, SerializedProperty actionMapProperty)
        {
            var bindingsArrayProperty = actionMapItem.bindingsProperty;
            var actionsArrayProperty  = actionMapItem.actionsProperty;

            for (var i = 0; i < actionsArrayProperty.arraySize; i++)
            {
                var action        = actionMap.actions[i];
                var actionItem    = new ActionTreeItem(actionMapProperty, action, actionsArrayProperty, i);
                var actionName    = action.name;
                var bindingsCount = InputActionSerializationHelpers.GetBindingCount(bindingsArrayProperty, actionName);

                bool actionSearchMatched = IsSearching() && actionName.ToLower().Contains(m_NameFilter.ToLower());

                CompositeGroupTreeItem compositeGroupTreeItem = null;
                for (var j = 0; j < bindingsCount; j++)
                {
                    var bindingProperty = InputActionSerializationHelpers.GetBinding(bindingsArrayProperty, actionName, j);
                    var binding         = action.bindings[j];
                    if (!string.IsNullOrEmpty(m_GroupFilter) && !binding.groups.Split(';').Contains(m_GroupFilter))
                    {
                        continue;
                    }
                    if (binding.isComposite)
                    {
                        compositeGroupTreeItem = new CompositeGroupTreeItem(actionMap.name, binding, bindingProperty, j);
                        actionItem.AddChild(compositeGroupTreeItem);
                        continue;
                    }
                    if (binding.isPartOfComposite)
                    {
                        var compositeItem = new CompositeTreeItem(actionMap.name, binding, bindingProperty, j);
                        if (compositeGroupTreeItem != null)
                        {
                            compositeGroupTreeItem.AddChild(compositeItem);
                        }
                        continue;
                    }
                    compositeGroupTreeItem = null;
                    var bindingsItem = new BindingTreeItem(actionMap.name, binding, bindingProperty, j);
                    if (!actionSearchMatched && IsSearching() && !binding.path.ToLower().Contains(m_NameFilter.ToLower()))
                    {
                        continue;
                    }
                    actionItem.AddChild(bindingsItem);
                }

                if (actionSearchMatched || IsSearching() && actionItem.children != null && actionItem.children.Any())
                {
                    actionMapItem.AddChild(actionItem);
                }
                else if (!IsSearching())
                {
                    actionMapItem.AddChild(actionItem);
                }
            }
        }
Ejemplo n.º 15
0
        private void OnAddCompositeBinding(object compositeAndProperty)
        {
            var compositeName = ((KeyValuePair <string, SerializedProperty>)compositeAndProperty).Key;
            var property      = ((KeyValuePair <string, SerializedProperty>)compositeAndProperty).Value;
            var compositeType = InputBindingComposite.s_Composites.LookupTypeRegistration(compositeName);

            InputActionSerializationHelpers.AddCompositeBinding(property, null, compositeName, compositeType);
            property.serializedObject.ApplyModifiedProperties();
            m_Tree.Reload();
        }
Ejemplo n.º 16
0
        internal void OnAddCompositeBinding(object paramList)
        {
            var compositeName = (string)((List <object>)paramList)[0];
            var property      = (SerializedProperty)((List <object>)paramList)[1];
            var compositeType = InputBindingComposite.s_Composites.LookupTypeRegistration(compositeName);

            InputActionSerializationHelpers.AddCompositeBinding(property, null, compositeName, compositeType);
            property.serializedObject.ApplyModifiedProperties();
            m_Tree.Reload();
        }
Ejemplo n.º 17
0
        public void SetUniqueName()
        {
            if (m_InputControlSchemeName == m_OriginalName)
            {
                return;
            }
            m_AssetManager.serializedObject.Update();
            var controlSchemeArrayProperty = m_AssetManager.serializedObject.FindProperty("m_ControlSchemes");

            m_InputControlSchemeName = InputActionSerializationHelpers.FindUniqueName(controlSchemeArrayProperty, m_InputControlSchemeName);
        }
Ejemplo n.º 18
0
        public ActionTreeItem(SerializedProperty actionMapProperty, SerializedProperty setProperty, int index)
            : base(setProperty, index)
        {
            m_ActionMapProperty = actionMapProperty;
            actionName          = elementProperty.FindPropertyRelative("m_Name").stringValue;
            bindingsStartIndex  = InputActionSerializationHelpers.GetBindingsStartIndex(m_ActionMapProperty.FindPropertyRelative("m_Bindings"), actionName);
            bindingsCount       = InputActionSerializationHelpers.GetBindingCount(m_ActionMapProperty.FindPropertyRelative("m_Bindings"), actionName);
            displayName         = actionName;
            var actionMapName = m_ActionMapProperty.FindPropertyRelative("m_Name").stringValue;

            id = (actionMapName + "/" + displayName).GetHashCode();
        }
Ejemplo n.º 19
0
        void DeleteSelectedRows()
        {
            var rows     = m_TreeView.GetSelectedRows().ToArray();
            var rowTypes = rows.Select(r => r.GetType()).Distinct().ToList();

            // Don't allow to delete different types at once because it's hard to handle.
            if (rowTypes.Count() > 1)
            {
                EditorApplication.Beep();
                return;
            }

            // Remove composite bindings
            foreach (var compositeGroup in FindRowsToDeleteOfType <CompositeGroupTreeItem>(rows))
            {
                var action = (compositeGroup.parent as ActionTreeItem);
                for (var i = compositeGroup.children.Count - 1; i >= 0; i--)
                {
                    var composite = (CompositeTreeItem)compositeGroup.children[i];
                    action.RemoveBinding(composite.index);
                }
                action.RemoveBinding(compositeGroup.index);
            }

            // Remove bindings
            foreach (var bindingRow in FindRowsToDeleteOfType <BindingTreeItem>(rows))
            {
                var action = bindingRow.parent as ActionTreeItem;
                action.RemoveBinding(bindingRow.index);
            }


            // Remove actions
            foreach (var actionRow in FindRowsToDeleteOfType <ActionTreeItem>(rows))
            {
                var action    = actionRow;
                var actionMap = actionRow.parent as ActionMapTreeItem;
                for (var i = actionRow.bindingsCount - 1; i >= 0; i--)
                {
                    action.RemoveBinding(i);
                }
                actionMap.DeleteAction(actionRow.index);
            }

            //Remove action maps
            foreach (var mapRow in FindRowsToDeleteOfType <ActionMapTreeItem>(rows))
            {
                InputActionSerializationHelpers.DeleteActionMap(m_SerializedObject, mapRow.index);
            }

            m_Window.Apply();
            m_Window.OnSelectionChanged();
        }
        public override void DeleteData()
        {
            var assetObject = property.serializedObject;

            if (!(assetObject.targetObject is InputActionAsset))
            {
                throw new InvalidOperationException(
                          $"Action map must be part of InputActionAsset but is in {assetObject.targetObject} instead");
            }

            InputActionSerializationHelpers.DeleteActionMap(assetObject, guid);
        }
Ejemplo n.º 21
0
        private void OnCompositeTypeChanged()
        {
            var nameAndParameters = new NameAndParameters
            {
                name       = m_CompositeTypes[m_SelectedCompositeType],
                parameters = m_CompositeParameters.GetParameters()
            };

            InputActionSerializationHelpers.ChangeCompositeBindingType(m_BindingProperty, nameAndParameters);
            m_PathProperty.serializedObject.ApplyModifiedProperties();

            onChange?.Invoke(k_CompositeTypeChanged);
        }
        void AddBinding(object propertyObj)
        {
            if (!CanAddBinding())
            {
                return;
            }
            var actionMapProperty = (SerializedProperty)propertyObj;
            var action            = m_TreeView.GetSelectedAction();

            InputActionSerializationHelpers.AppendBinding(action.elementProperty, actionMapProperty);
            action.elementProperty.serializedObject.ApplyModifiedProperties();
            m_TreeView.Reload();
        }
Ejemplo n.º 23
0
        private void MoveAction(DragAndDropArgs args, ActionTreeViewItem row)
        {
            var action = (ActionTreeItem)row;

            var dstIndex = args.insertAtIndex;
            var srcIndex = action.index;

            if (dstIndex > srcIndex)
            {
                dstIndex--;
            }
            InputActionSerializationHelpers.MoveAction(actionMapProperty, srcIndex, dstIndex);
        }
Ejemplo n.º 24
0
        private void OnDelete(object data)
        {
            var list = (IList <int>)data;

            // Sort actions by action index such that we delete actions from high to
            // low indices. This way indices won't shift as we delete actions.
            var array = list.Select(x => FindItem(x, rootItem)).ToArray();

            Array.Sort(array, (a, b) =>
            {
                var aActionItem = a as ActionItem;
                var bActionItem = b as ActionItem;

                if (aActionItem != null && bActionItem != null)
                {
                    if (aActionItem.actionIndex < bActionItem.actionIndex)
                    {
                        return(1);
                    }
                    if (aActionItem.actionIndex > bActionItem.actionIndex)
                    {
                        return(-1);
                    }
                }

                return(0);
            });

            // First delete actions, then sets.
            foreach (var item in array)
            {
                if (item is ActionItem)
                {
                    var actionItem    = (ActionItem)item;
                    var actionSetItem = (ActionSetItem)actionItem.parent;
                    InputActionSerializationHelpers.DeleteAction(actionSetItem.property, actionItem.actionIndex);
                }
            }
            foreach (var item in array)
            {
                if (item is ActionSetItem)
                {
                    var actionSetItem = (ActionSetItem)item;
                    InputActionSerializationHelpers.DeleteActionMap(actionSetItem.property.serializedObject, actionSetItem.actionSetIndex);
                }
            }

            m_ApplyAction();
            Reload();
        }
Ejemplo n.º 25
0
        private void InitializeCompositePartProperties()
        {
            var currentCompositePart = m_BindingProperty.FindPropertyRelative("m_Name").stringValue;

            ////REVIEW: this makes a lot of assumptions about the serialized data based on the one property we've been given in the ctor
            // Determine the name of the current composite type that the part belongs to.
            var bindingArrayProperty  = m_BindingProperty.GetArrayPropertyFromElement();
            var partBindingIndex      = InputActionSerializationHelpers.GetIndex(bindingArrayProperty, m_BindingProperty);
            var compositeBindingIndex =
                InputActionSerializationHelpers.GetCompositeStartIndex(bindingArrayProperty, partBindingIndex);

            if (compositeBindingIndex == -1)
            {
                return;
            }
            var compositeBindingProperty   = bindingArrayProperty.GetArrayElementAtIndex(compositeBindingIndex);
            var compositePath              = compositeBindingProperty.FindPropertyRelative("m_Path").stringValue;
            var compositeNameAndParameters = NameAndParameters.Parse(compositePath);

            // Initialize option list from all parts available for the composite.
            var optionList            = new List <GUIContent>();
            var nameList              = new List <string>();
            var currentIndex          = 0;
            var selectedPartNameIndex = -1;

            foreach (var partName in InputBindingComposite.GetPartNames(compositeNameAndParameters.name))
            {
                if (partName.Equals(currentCompositePart, StringComparison.InvariantCultureIgnoreCase))
                {
                    selectedPartNameIndex = currentIndex;
                }
                var niceName = ObjectNames.NicifyVariableName(partName);
                optionList.Add(new GUIContent(niceName));
                nameList.Add(partName);
                ++currentIndex;
            }

            // If currently selected part is not in list, add it as an option.
            if (selectedPartNameIndex == -1)
            {
                selectedPartNameIndex = nameList.Count;
                optionList.Add(new GUIContent(ObjectNames.NicifyVariableName(currentCompositePart)));
                nameList.Add(currentCompositePart);
            }

            m_CompositeParts        = nameList.ToArray();
            m_CompositePartOptions  = optionList.ToArray();
            m_SelectedCompositePart = selectedPartNameIndex;
        }
        void OnAddCompositeBinding(object paramList)
        {
            if (!CanAddBinding())
            {
                return;
            }
            var compositeName = (string)((List <object>)paramList)[0];
            var mapProperty   = (SerializedProperty)((List <object>)paramList)[1];
            var action        = m_TreeView.GetSelectedAction();
            var compositeType = InputBindingComposite.s_Composites.LookupTypeRegistration(compositeName);

            InputActionSerializationHelpers.AppendCompositeBinding(action.elementProperty, mapProperty, compositeName, compositeType);
            mapProperty.serializedObject.ApplyModifiedProperties();
            m_TreeView.Reload();
        }
Ejemplo n.º 27
0
        protected void AddActionSet()
        {
            InputActionSerializationHelpers.AddActionMap(serializedObject);
            ++m_ActionMapCount;

            Apply();

            if (m_ActionTreeView == null)
            {
                InitializeActionTreeView();
            }
            else
            {
                m_ActionTreeView.Reload();
            }
        }
Ejemplo n.º 28
0
        private void MoveBinding(DragAndDropArgs args, ActionTreeViewItem row)
        {
            TreeViewItem item;
            var          compositeChildrenCount = 0;

            for (var i = 0; i < args.insertAtIndex; i++)
            {
                item = args.parentItem.children[i];
                if (item.hasChildren)
                {
                    compositeChildrenCount += item.children.Count;
                }
            }

            args.insertAtIndex += compositeChildrenCount;

            var action = (ActionTreeItem)args.parentItem;

            var dstIndex = action.bindingsStartIndex + args.insertAtIndex;
            var srcIndex = action.bindingsStartIndex + row.index;

            if (dstIndex > srcIndex)
            {
                dstIndex--;
            }

            InputActionSerializationHelpers.MoveBinding(actionMapProperty, srcIndex, dstIndex);

            if (row.hasChildren)
            {
                for (var i = 0; i < row.children.Count; i++)
                {
                    if (dstIndex > srcIndex)
                    {
                        // when moving composite down
                        InputActionSerializationHelpers.MoveBinding(actionMapProperty, srcIndex, dstIndex);
                        continue;
                    }

                    // when moving composite up
                    dstIndex++;
                    srcIndex = action.bindingsStartIndex + (row.children[i] as CompositeTreeItem).index;
                    InputActionSerializationHelpers.MoveBinding(actionMapProperty, srcIndex, dstIndex);
                }
            }
        }
        protected override void RenameEnded(RenameEndedArgs args)
        {
            var item = FindItem(args.itemID, rootItem);

            if (item == null)
            {
                return;
            }

            (item as InputTreeViewLine).renaming = false;

            if (!args.acceptedRename)
            {
                return;
            }

            var actionItem = item as InputTreeViewLine;

            if (actionItem == null)
            {
                return;
            }

            if (actionItem is ActionTreeItem)
            {
                var map = GetSelectedActionMap();
                InputActionSerializationHelpers.RenameAction(actionItem.elementProperty, map.elementProperty, args.newName);
            }
            else if (actionItem is ActionMapTreeItem)
            {
                InputActionSerializationHelpers.RenameActionMap(actionItem.elementProperty, args.newName);
            }
            else if (actionItem is CompositeGroupTreeItem)
            {
                InputActionSerializationHelpers.RenameComposite(actionItem.elementProperty, args.newName);
            }
            else
            {
                throw new NotImplementedException("Can't rename this row");
            }

            m_ApplyAction();

            item.displayName = args.newName;
            Reload();
        }
Ejemplo n.º 30
0
 public ActionTreeItem(SerializedProperty actionMapProperty, SerializedProperty actionProperty, int index)
     : base(actionProperty, index)
 {
     m_ActionMapProperty = actionMapProperty;
     actionName          = elementProperty.FindPropertyRelative("m_Name").stringValue;
     if (m_ActionMapProperty != null)
     {
         bindingsStartIndex = InputActionSerializationHelpers.GetBindingsStartIndex(m_ActionMapProperty.FindPropertyRelative("m_Bindings"), actionName);
         bindingsCount      = InputActionSerializationHelpers.GetBindingCount(m_ActionMapProperty.FindPropertyRelative("m_Bindings"), actionName);
     }
     else
     {
         bindingsStartIndex = 0;
         bindingsCount      = InputActionSerializationHelpers.GetBindingCount(elementProperty.FindPropertyRelative("m_SingletonActionBindings"), actionName);
     }
     displayName = actionName;
     id          = GetIdForName(displayName);
 }