TreeViewItem BuildFromActionMapSerializedProperty() { var actionMapItem = new ActionMapTreeItem(m_ActionMapSerializedProperty, 0); actionMapItem.depth = -1; actionMapItem.children = new List <TreeViewItem>(); ParseActionMap(actionMapItem, m_ActionMapSerializedProperty, 0); return(actionMapItem); }
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); } } }
public static ActionMapTreeItem AddTo(TreeViewItem parent, SerializedProperty actionMapProperty) { var item = new ActionMapTreeItem(actionMapProperty); item.depth = parent.depth + 1; item.displayName = item.name; parent.AddChild(item); return(item); }
private void BuildFromSerializedObject(TreeViewItem root) { var actionMapArrayProperty = m_SerializedObject.FindProperty("m_ActionMaps"); for (var i = 0; i < actionMapArrayProperty.arraySize; i++) { var actionMapProperty = actionMapArrayProperty.GetArrayElementAtIndex(i); var actionMapItem = new ActionMapTreeItem(actionMapProperty, i); root.AddChild(actionMapItem); } }
protected override TreeViewItem BuildRoot() { var root = new TreeViewItem { id = 0, depth = -1 }; root.children = new List <TreeViewItem>(); m_SerializedObject.Update(); var actionMapsProperty = m_SerializedObject.FindProperty("m_ActionMaps"); for (var i = 0; i < m_Asset.actionMaps.Count; i++) { var actionMap = m_Asset.actionMaps[i]; var actionItem = new ActionMapTreeItem(actionMap, actionMapsProperty, i); ParseActionMap(actionItem, actionMap, actionItem.elementProperty); root.AddChild(actionItem); } return(root); }