diff --git a/Scripts/Editor/NodeEditorGUI.cs b/Scripts/Editor/NodeEditorGUI.cs index a88e1b0..19ee749 100755 --- a/Scripts/Editor/NodeEditorGUI.cs +++ b/Scripts/Editor/NodeEditorGUI.cs @@ -556,28 +556,20 @@ namespace XNodeEditor { } private void DrawTooltip() { - if (!NodeEditorPreferences.GetSettings().portTooltips && graphEditor != null) + if (!NodeEditorPreferences.GetSettings().portTooltips || graphEditor is null) return; - if (hoveredPort != null) { - string tooltip = graphEditor.GetPortTooltip(hoveredPort); - if (string.IsNullOrEmpty(tooltip)) return; - GUIContent content = new GUIContent(tooltip); - Vector2 size = NodeEditorResources.styles.tooltip.CalcSize(content); - size.x += 8; - Rect rect = new Rect(Event.current.mousePosition - (size), size); - EditorGUI.LabelField(rect, content, NodeEditorResources.styles.tooltip); - Repaint(); - } - else if (hoveredNode != null && IsHoveringNode && IsHoveringTitle(hoveredNode)) { - string tooltip = graphEditor.GetNodeTooltip(hoveredNode); - if (string.IsNullOrEmpty(tooltip)) return; - GUIContent content = new GUIContent(tooltip); - Vector2 size = NodeEditorResources.styles.tooltip.CalcSize(content); - size.x += 8; - Rect rect = new Rect(Event.current.mousePosition - (size), size); - EditorGUI.LabelField(rect, content, NodeEditorResources.styles.tooltip); - Repaint(); - } + string tooltip = null; + if (hoveredPort != null && IsHoveringPort) + tooltip = graphEditor.GetPortTooltip(hoveredPort); + else if (hoveredNode != null && IsHoveringNode && IsHoveringTitle(hoveredNode)) + tooltip = graphEditor.GetNodeTooltip(hoveredNode); + if (string.IsNullOrEmpty(tooltip)) return; + GUIContent content = new GUIContent(tooltip); + Vector2 size = NodeEditorResources.styles.tooltip.CalcSize(content); + size.x += 8; + Rect rect = new Rect(Event.current.mousePosition - (size), size); + EditorGUI.LabelField(rect, content, NodeEditorResources.styles.tooltip); + Repaint(); } } } diff --git a/Scripts/Editor/NodeGraphEditor.cs b/Scripts/Editor/NodeGraphEditor.cs index d2bf45c..dca851e 100644 --- a/Scripts/Editor/NodeGraphEditor.cs +++ b/Scripts/Editor/NodeGraphEditor.cs @@ -158,6 +158,7 @@ namespace XNodeEditor { return tooltip; } + /// Override to display custom node tooltips public virtual string GetNodeTooltip(XNode.Node node) { return null; }