private static void ToggleFocusUsingKeyboard(KeyCode key, InputActionTreeView fromTree, InputActionTreeView toTree) { var uiEvent = Event.current; if (uiEvent.type == EventType.KeyDown && uiEvent.keyCode == key && fromTree.HasFocus()) { if (!toTree.HasSelection()) { toTree.SelectFirstToplevelItem(); } toTree.SetFocus(); uiEvent.Use(); } }
private void InitializeTrees() { // We persist tree view states (most importantly, they contain our selection states), // so only create those if we don't have any yet. if (m_ActionMapsTreeState == null) { m_ActionMapsTreeState = new TreeViewState(); } if (m_ActionsTreeState == null) { m_ActionsTreeState = new TreeViewState(); } // Create tree in middle pane showing actions and bindings. We initially // leave this tree empty and populate it by selecting an action map in the // left pane tree. m_ActionsTree = new InputActionTreeView(m_ActionAssetManager.serializedObject, m_ActionsTreeState) { onSelectionChanged = OnActionTreeSelectionChanged, onSerializedObjectModified = ApplyAndReloadTrees, onBindingAdded = p => InputActionSerializationHelpers.RemoveUnusedBindingGroups(p, m_Toolbar.controlSchemes), drawMinusButton = false, title = ("Actions", "A list of InputActions in the InputActionMap selected in the left pane. Also, for each InputAction, the list " + "of bindings that determine the controls that can trigger the action.\n\nThe name of each action must be unique within its InputActionMap."), }; // Create tree in left pane showing action maps. m_ActionMapsTree = new InputActionTreeView(m_ActionAssetManager.serializedObject, m_ActionMapsTreeState) { onBuildTree = () => InputActionTreeView.BuildWithJustActionMapsFromAsset(m_ActionAssetManager.serializedObject), onSelectionChanged = OnActionMapTreeSelectionChanged, onSerializedObjectModified = ApplyAndReloadTrees, onHandleAddNewAction = m_ActionsTree.AddNewAction, drawMinusButton = false, title = ("Action Maps", "A list of InputActionMaps in the asset. Each map can be enabled and disabled separately at runtime and holds " + "its own collection of InputActions which are listed in the middle pane (along with their InputBindings).") }; m_ActionMapsTree.Reload(); m_ActionMapsTree.ExpandAll(); RebuildActionTree(); LoadPropertiesForSelection(); // Sync current search status in toolbar. OnToolbarSearchChanged(); }
private void InitializeTrees() { // We persist tree view states (most importantly, they contain our selection states), // so only create those if we don't have any yet. if (m_ActionMapsTreeState == null) { m_ActionMapsTreeState = new TreeViewState(); } if (m_ActionsTreeState == null) { m_ActionsTreeState = new TreeViewState(); } // Create tree in middle pane showing actions and bindings. We initially // leave this tree empty and populate it by selecting an action map in the // left pane tree. m_ActionsTree = new InputActionTreeView(m_ActionAssetManager.serializedObject, m_ActionsTreeState) { onSelectionChanged = OnActionTreeSelectionChanged, onSerializedObjectModified = ApplyAndReloadTrees, drawMinusButton = false, title = "Actions", }; // Create tree in left pane showing action maps. m_ActionMapsTree = new InputActionTreeView(m_ActionAssetManager.serializedObject, m_ActionMapsTreeState) { onBuildTree = () => InputActionTreeView.BuildWithJustActionMapsFromAsset(m_ActionAssetManager.serializedObject), onSelectionChanged = OnActionMapTreeSelectionChanged, onSerializedObjectModified = ApplyAndReloadTrees, onHandleAddNewAction = m_ActionsTree.AddNewAction, drawMinusButton = false, title = "Action Maps", }; m_ActionMapsTree.Reload(); m_ActionMapsTree.ExpandAll(); RebuildActionTree(); LoadPropertiesForSelection(); // Sync current search status in toolbar. OnToolbarSearchChanged(); }
private void RebuildActionTree() { var selectedActionMapItem = m_ActionMapsTree.GetSelectedItems().OfType <ActionMapTreeItem>().FirstOrDefault(); if (selectedActionMapItem == null) { // Nothing selected. Wipe middle and right pane. m_ActionsTree.onBuildTree = null; } else { m_ActionsTree.onBuildTree = () => InputActionTreeView.BuildWithJustActionsAndBindingsFromMap(selectedActionMapItem.property); } // Rebuild tree. m_ActionsTree.Reload(); }
private void InitTreeIfNeeded(SerializedProperty property) { // NOTE: Unlike InputActionEditorWindow, we do not need to protect against the SerializedObject // changing behind our backs by undo/redo here. Being a PropertyDrawer, we will automatically // get recreated by Unity when it touches our serialized data. if (m_TreeView == null) { // Create tree and populate it. m_TreeView = new InputActionTreeView(property.serializedObject) { onBuildTree = () => BuildTree(property), onDoubleClick = OnItemDoubleClicked, title = property.displayName, // With the tree in the inspector, the foldouts are drawn too far to the left. I don't // really know where this is coming from. This works around it by adding an arbitrary offset... foldoutOffset = 14 }; m_TreeView.Reload(); } }
protected override TreeViewItem BuildTree(SerializedProperty property) { return(InputActionTreeView.BuildWithJustActionsAndBindingsFromMap(property)); }