Ejemplo n.º 1
0
 private ActionMapTreeItem GetSelectedActionMap()
 {
     if (m_Tree != null)
     {
         return(m_Tree.GetSelectedActionMap());
     }
     return(m_ActionMapsTree?.GetSelectedActionMap());
 }
Ejemplo n.º 2
0
        internal void Apply()
        {
            m_ActionAssetManager.SetAssetDirty();
            titleContent = m_DirtyTitle;
            m_ActionAssetManager.ApplyChanges();
            m_ActionMapsTree.Reload();
            m_InputActionWindowToolbar.RebuildData();
            var selectedActionMap = m_ActionMapsTree.GetSelectedActionMap();

            if (selectedActionMap != null)
            {
                m_ActionsTree.actionMapProperty = m_ActionMapsTree.GetSelectedActionMap().elementProperty;
            }
            else
            {
                m_ActionsTree.actionMapProperty = null;
            }
            m_ActionsTree.Reload();
        }
Ejemplo n.º 3
0
        private void DeleteSelectedRows()
        {
            var rows     = 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;
                ActionMapTreeItem actionMap;
                if (m_Tree != null)
                {
                    actionMap = actionRow.parent as ActionMapTreeItem;
                }
                else
                {
                    actionMap = m_ActionMapsTree.GetSelectedActionMap();
                }

                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);
            }

            SetEmptySelection();
            m_Apply();
        }