Exemplo n.º 1
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);
            }
        }
        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);
                }
            }
        }
Exemplo n.º 3
0
        protected void ParseBindings(TreeViewItem parent, string actionMapName, string actionName, SerializedProperty bindingsArrayProperty, int depth)
        {
            bool actionSearchMatched = IsSearching() && actionName.ToLower().Contains(m_NameFilter.ToLower());
            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 (!string.IsNullOrEmpty(m_GroupFilter) && !bindingsItem.groups.Split(';').Contains(m_GroupFilter))
                {
                    continue;
                }
                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;
                if (!actionSearchMatched && IsSearching() && !bindingsItem.path.ToLower().Contains(m_NameFilter.ToLower()))
                {
                    continue;
                }
                parent.AddChild(bindingsItem);
            }
        }