private void OnGUI() { if (Event.current.type == EventType.KeyDown) { if (m_ActionMapsTree.HasFocus() && Event.current.keyCode == KeyCode.RightArrow) { if (!m_ActionsTree.HasSelection()) { m_ActionsTree.SelectFirstRow(); } m_ActionsTree.SetFocus(); } } EditorGUILayout.BeginVertical(); m_InputActionWindowToolbar.OnGUI(); EditorGUILayout.Space(); var isPickingInteractively = m_BindingPropertyView != null && m_BindingPropertyView.isInteractivelyPicking; EditorGUI.BeginDisabledGroup(isPickingInteractively); // Draw columns. var columnsRect = EditorGUILayout.BeginHorizontal(); var columnAreaWidth = position.width - Styles.actionTreeBackground.margin.left - Styles.actionTreeBackground.margin.left - Styles.propertiesBackground.margin.right; DrawActionMapsColumn(columnAreaWidth * 0.22f); DrawActionsColumn(columnAreaWidth * 0.38f); DrawPropertiesColumn(columnAreaWidth * 0.40f); EditorGUILayout.EndHorizontal(); // If we're currently interactively picking a binding, aside from disabling and dimming the normal UI, display a large text over // the window that says we're waiting for input. // NOTE: We're not using EditorWindow.ShowNotification() as, aside from having trouble displaying our dynamically generated text // properly without clipping, notifications will automatically disappear after a brief moment. We want the input requester // to stay visible for as long as we're still looking for input. EditorGUI.EndDisabledGroup(); if (isPickingInteractively) { DrawInteractivePickingOverlay(columnsRect); } // Bottom margin. GUILayout.Space(3); EditorGUILayout.EndVertical(); if (Event.current.type == EventType.ValidateCommand) { if (InputActionCopyPasteUtility.IsValidCommand(Event.current.commandName)) { Event.current.Use(); } } if (Event.current.type == EventType.ExecuteCommand) { m_CopyPasteUtility.HandleCommandEvent(Event.current.commandName); } }
private void InitTreeIfNeeded(SerializedProperty property) { if (m_Tree == null) { m_Tree = CreateTree(property); m_Tree.OnContextClick = OnContextClick; m_CopyPasteUtility = new InputActionCopyPasteUtility(m_Tree); } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); SetActionNameIfNotSet(property); var labelRect = position; EditorGUI.LabelField(labelRect, GUIContent.none, Styles.actionTreeBackground); var headerRect = new Rect(labelRect.x + 1, labelRect.y + 1, labelRect.width - 2, labelRect.height - 2); EditorGUI.LabelField(headerRect, label, Styles.columnHeaderLabel); labelRect.x = labelRect.width - (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing); labelRect.width = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; if (GUI.Button(labelRect, m_PlusIconContent, GUIStyle.none)) { OpenAddMenu(property); } labelRect.x += labelRect.width; if (GUI.Button(labelRect, m_MinusIconContent, GUIStyle.none)) { EditorWindow.focusedWindow.SendEvent(EditorGUIUtility.CommandEvent("Delete")); } InitTreeIfNeeded(property); position.y += Styles.columnHeaderLabel.fixedHeight; var treeRect = new Rect(position.x + 1, position.y + 1, position.width - 2, position.height - Styles.columnHeaderLabel.fixedHeight - 2); m_Tree.OnGUI(treeRect); if (m_Tree.HasFocus()) { if (Event.current.type == EventType.ValidateCommand) { if (InputActionCopyPasteUtility.IsValidCommand(Event.current.commandName)) { Event.current.Use(); } } else if (Event.current.type == EventType.ExecuteCommand) { m_CopyPasteUtility.HandleCommandEvent(Event.current.commandName); } } EditorGUI.EndProperty(); }
private void InitializeTrees() { m_ActionMapsTree = ActionMapsTree.CreateFromSerializedObject(ApplyAndReload, m_ActionAssetManager.serializedObject, ref m_ActionMapsTreeState); m_ActionMapsTree.OnSelectionChanged = OnActionMapSelection; m_ActionMapsTree.OnContextClick = m_ContextMenu.OnActionMapContextClick; m_ActionsTree = ActionsTree.CreateFromSerializedObject(ApplyAndReload, ref m_ActionsTreeState); m_ActionsTree.OnSelectionChanged = OnActionSelection; m_ActionsTree.OnContextClick = m_ContextMenu.OnActionsContextClick; m_ActionsTree.OnRowGUI = OnActionRowGUI; m_InputActionWindowToolbar.OnSearchChanged = m_ActionsTree.SetNameFilter; m_InputActionWindowToolbar.OnSchemeChanged = a => { if (a == null) { m_ActionsTree.SetSchemeBindingGroupFilter(null); return; } var group = m_ActionAssetManager.m_AssetObjectForEditing.GetControlScheme(a).bindingGroup; m_ActionsTree.SetSchemeBindingGroupFilter(group); }; m_InputActionWindowToolbar.OnDeviceChanged = m_ActionsTree.SetDeviceFilter; m_ActionsTree.SetNameFilter(m_InputActionWindowToolbar.nameFilter); if (m_InputActionWindowToolbar.selectedControlSchemeName != null) { var group = m_ActionAssetManager.m_AssetObjectForEditing.GetControlScheme(m_InputActionWindowToolbar.selectedControlSchemeName).bindingGroup; m_ActionsTree.SetSchemeBindingGroupFilter(group); } m_ActionsTree.SetDeviceFilter(m_InputActionWindowToolbar.selectedDevice); m_CopyPasteUtility = new InputActionCopyPasteUtility(ApplyAndReload, m_ActionMapsTree, m_ActionsTree, m_ActionAssetManager.serializedObject); if (m_PickerTreeViewState == null) { m_PickerTreeViewState = new InputControlPickerState(); } }