public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); // If the action has no name, infer it from the name of the action property. SetActionNameIfNotSet(property); var foldoutRect = position; foldoutRect.height = kFoldoutHeight; var btnRect = foldoutRect; btnRect.x = btnRect.width - 20; btnRect.width = 20; foldoutRect.width -= 20; property.isExpanded = EditorGUI.Foldout(foldoutRect, property.isExpanded, label); if (property.isExpanded) { position.y += kFoldoutHeight + 2; position.x += kBindingIndent; position.width -= kBindingIndent; InitTreeIfNeeded(property); if (GUI.Button(btnRect, "+")) { OpenAddMenu(property); } m_TreeView.OnGUI(position); if (Event.current.type == EventType.ValidateCommand) { if (Event.current.commandName == "Delete") { Event.current.Use(); } } if (Event.current.type == EventType.ExecuteCommand) { if (Event.current.commandName == "Delete") { DeleteSelectedRows(property); Event.current.Use(); } } } EditorGUI.EndProperty(); }
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; var plusIconContext = EditorGUIUtility.IconContent("Toolbar Plus"); if (GUI.Button(labelRect, plusIconContext, GUIStyle.none)) { OpenAddMenu(property); } 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_TreeView.OnGUI(treeRect); if (m_TreeView.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 DrawMainTree() { EditorGUILayout.BeginVertical(Styles.actionTreeBackground); GUILayout.FlexibleSpace(); EditorGUILayout.EndVertical(); var treeViewRect = GUILayoutUtility.GetLastRect(); var labelRect = new Rect(treeViewRect); labelRect.height = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing * 2; treeViewRect.y += labelRect.height; treeViewRect.height -= labelRect.height; treeViewRect.x += 1; treeViewRect.width -= 2; GUIContent header; if (string.IsNullOrEmpty(m_SearchText)) { header = EditorGUIUtility.TrTextContent("Action maps"); } else { header = EditorGUIUtility.TrTextContent("Action maps (Searching)"); } 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, header, Styles.columnHeaderLabel); labelRect.x = labelRect.width - (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing); labelRect.width = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; var plusIconContext = EditorGUIUtility.IconContent("Toolbar Plus"); if (GUI.Button(labelRect, plusIconContext, GUIStyle.none)) { ShowAddMenu(); } m_TreeView.OnGUI(treeViewRect); }
void DrawMainTree() { EditorGUILayout.BeginVertical(Styles.darkGreyBackgroundWithBorder); GUILayout.FlexibleSpace(); EditorGUILayout.EndVertical(); var treeViewRect = GUILayoutUtility.GetLastRect(); var labelRect = new Rect(treeViewRect); labelRect.height = 20; treeViewRect.y += 20; treeViewRect.height -= 20; treeViewRect.x += 1; treeViewRect.width -= 2; var header = "Action maps"; if (!string.IsNullOrEmpty(m_SearchText)) { header += " (Searching)"; } EditorGUI.LabelField(labelRect, GUIContent.none, Styles.darkGreyBackgroundWithBorder); var headerRect = new Rect(labelRect.x + 1, labelRect.y + 1, labelRect.width - 2, labelRect.height - 2); EditorGUI.LabelField(headerRect, header, Styles.columnHeaderLabel); labelRect.x = labelRect.width - 18; labelRect.width = 18; var plusIconContext = EditorGUIUtility.IconContent("Toolbar Plus"); if (GUI.Button(labelRect, plusIconContext, GUIStyle.none)) { ShowAddMenu(); } m_TreeView.OnGUI(treeViewRect); }