private void InitTreeIfNeeded(SerializedProperty property) { if (m_TreeView == null) { m_TreeView = CreateTree(property); m_TreeView.OnContextClick = OnContextClick; m_CopyPasteUtility = new CopyPasteUtility(m_TreeView); } }
void InitiateTrees() { if (m_SerializedObject != null) { m_SearchField = new SearchField(); m_TreeView = InputActionListTreeView.Create(Apply, m_ReferencedObject as InputActionAsset, m_SerializedObject, ref m_TreeViewState); m_TreeView.OnSelectionChanged = OnSelectionChanged; m_TreeView.OnContextClick = OnContextClick; m_CopyPasteUtility = new CopyPasteUtility(this, m_TreeView, m_SerializedObject); LoadPropertiesForSelection(); } }
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_PlusIconContext, GUIStyle.none)) { OpenAddMenu(property); } labelRect.x += labelRect.width; if (GUI.Button(labelRect, m_MinusIconContext, 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 (CopyPasteUtility.IsValidCommand(Event.current.commandName)) { Event.current.Use(); } } if (Event.current.type == EventType.ExecuteCommand) { m_CopyPasteUtility.HandleCommandEvent(Event.current.commandName); } } EditorGUI.EndProperty(); }
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(); // Toolbar. EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); m_InputActionWindowToolbar.OnGUI(); GUILayout.Space(5); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); //Draw columns EditorGUILayout.BeginHorizontal(); var columnOneRect = GUILayoutUtility.GetRect(0, 0, 0, 0, Styles.actionTreeBackground, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true)); var columnTwoRect = GUILayoutUtility.GetRect(0, 0, 0, 0, Styles.actionTreeBackground, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true)); DrawActionMapsColumn(columnOneRect); DrawActionsColumn(columnTwoRect); DrawPropertiesColumn(); EditorGUILayout.EndHorizontal(); // Bottom margin GUILayout.Space(3); EditorGUILayout.EndVertical(); if (Event.current.type == EventType.ValidateCommand) { if (CopyPasteUtility.IsValidCommand(Event.current.commandName)) { Event.current.Use(); } } if (Event.current.type == EventType.ExecuteCommand) { m_CopyPasteUtility.HandleCommandEvent(Event.current.commandName); } }
void InitializeTrees() { if (m_SerializedObject != null) { m_SearchField = new SearchField(); m_TreeView = InputActionListTreeView.CreateFromSerializedObject(Apply, m_SerializedObject, ref m_TreeViewState); m_TreeView.OnSelectionChanged = OnSelectionChanged; m_TreeView.OnContextClick = OnContextClick; m_CopyPasteUtility = new CopyPasteUtility(Apply, m_TreeView, m_SerializedObject); if (m_PickerTreeViewState == null) { m_PickerTreeViewState = new TreeViewState(); } LoadPropertiesForSelection(); } }
public void OnGUI() { EditorGUILayout.BeginVertical(); // Toolbar. EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); EditorGUI.BeginDisabledGroup(!m_IsDirty); if (GUILayout.Button(m_SaveAssetGUI, EditorStyles.toolbarButton)) { SaveChangesToAsset(); } EditorGUI.EndDisabledGroup(); GUILayout.FlexibleSpace(); EditorGUI.BeginChangeCheck(); m_SearchText = m_SearchField.OnToolbarGUI(m_SearchText, GUILayout.MaxWidth(250)); if (EditorGUI.EndChangeCheck()) { m_TreeView.SetNameFilter(m_SearchText); } GUILayout.Space(5); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); DrawMainTree(); DrawProperties(); EditorGUILayout.EndHorizontal(); GUILayout.Space(3); EditorGUILayout.EndVertical(); if (Event.current.type == EventType.ValidateCommand) { if (CopyPasteUtility.IsValidCommand(Event.current.commandName)) { Event.current.Use(); } } if (Event.current.type == EventType.ExecuteCommand) { m_CopyPasteUtility.HandleCommandEvent(Event.current.commandName); } }
private void InitializeTrees() { m_ActionMapsTree = ActionMapsTree.CreateFromSerializedObject(Apply, m_ActionAssetManager.serializedObject, ref m_ActionMapsTreeState); m_ActionMapsTree.OnSelectionChanged = OnActionMapSelection; m_ActionMapsTree.OnContextClick = m_ContextMenu.OnActionMapContextClick; m_ActionsTree = ActionsTree.CreateFromSerializedObject(Apply, 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 CopyPasteUtility(Apply, m_ActionMapsTree, m_ActionsTree, m_ActionAssetManager.serializedObject); if (m_PickerTreeViewState == null) { m_PickerTreeViewState = new TreeViewState(); } }
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(); // Toolbar. EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); m_InputActionWindowToolbar.OnGUI(); GUILayout.Space(5); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); var isPickingInteractively = m_BindingPropertyView != null && m_BindingPropertyView.isInteractivelyPicking; EditorGUI.BeginDisabledGroup(isPickingInteractively); // Draw columns. var columnsRect = EditorGUILayout.BeginHorizontal(); var columnOneRect = GUILayoutUtility.GetRect(0, 0, 0, 0, Styles.actionTreeBackground, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true)); var columnTwoRect = GUILayoutUtility.GetRect(0, 0, 0, 0, Styles.actionTreeBackground, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true)); DrawActionMapsColumn(columnOneRect); DrawActionsColumn(columnTwoRect); DrawPropertiesColumn(); 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 (CopyPasteUtility.IsValidCommand(Event.current.commandName)) { Event.current.Use(); } } if (Event.current.type == EventType.ExecuteCommand) { m_CopyPasteUtility.HandleCommandEvent(Event.current.commandName); } }