1
0
mirror of https://github.com/Siccity/xNode.git synced 2026-03-26 22:49:02 +08:00

# fix bug

This commit is contained in:
mayuntian 2020-08-10 16:49:31 +08:00
parent cdb08154e2
commit f19ac7a2f7
2 changed files with 14 additions and 21 deletions

View File

@ -556,28 +556,20 @@ namespace XNodeEditor {
} }
private void DrawTooltip() { private void DrawTooltip() {
if (!NodeEditorPreferences.GetSettings().portTooltips && graphEditor != null) if (!NodeEditorPreferences.GetSettings().portTooltips || graphEditor is null)
return; return;
if (hoveredPort != null) { string tooltip = null;
string tooltip = graphEditor.GetPortTooltip(hoveredPort); if (hoveredPort != null && IsHoveringPort)
if (string.IsNullOrEmpty(tooltip)) return; tooltip = graphEditor.GetPortTooltip(hoveredPort);
GUIContent content = new GUIContent(tooltip); else if (hoveredNode != null && IsHoveringNode && IsHoveringTitle(hoveredNode))
Vector2 size = NodeEditorResources.styles.tooltip.CalcSize(content); tooltip = graphEditor.GetNodeTooltip(hoveredNode);
size.x += 8; if (string.IsNullOrEmpty(tooltip)) return;
Rect rect = new Rect(Event.current.mousePosition - (size), size); GUIContent content = new GUIContent(tooltip);
EditorGUI.LabelField(rect, content, NodeEditorResources.styles.tooltip); Vector2 size = NodeEditorResources.styles.tooltip.CalcSize(content);
Repaint(); size.x += 8;
} Rect rect = new Rect(Event.current.mousePosition - (size), size);
else if (hoveredNode != null && IsHoveringNode && IsHoveringTitle(hoveredNode)) { EditorGUI.LabelField(rect, content, NodeEditorResources.styles.tooltip);
string tooltip = graphEditor.GetNodeTooltip(hoveredNode); Repaint();
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();
}
} }
} }
} }

View File

@ -158,6 +158,7 @@ namespace XNodeEditor {
return tooltip; return tooltip;
} }
/// <summary> Override to display custom node tooltips </summary>
public virtual string GetNodeTooltip(XNode.Node node) { public virtual string GetNodeTooltip(XNode.Node node) {
return null; return null;
} }