mirror of
https://github.com/Siccity/xNode.git
synced 2026-03-26 22:49:02 +08:00
# add Node header tooltip
This commit is contained in:
parent
abb4ea8208
commit
cdb08154e2
@ -556,7 +556,9 @@ namespace XNodeEditor {
|
||||
}
|
||||
|
||||
private void DrawTooltip() {
|
||||
if (hoveredPort != null && NodeEditorPreferences.GetSettings().portTooltips && graphEditor != null) {
|
||||
if (!NodeEditorPreferences.GetSettings().portTooltips && graphEditor != null)
|
||||
return;
|
||||
if (hoveredPort != null) {
|
||||
string tooltip = graphEditor.GetPortTooltip(hoveredPort);
|
||||
if (string.IsNullOrEmpty(tooltip)) return;
|
||||
GUIContent content = new GUIContent(tooltip);
|
||||
@ -566,6 +568,16 @@ namespace XNodeEditor {
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -158,6 +158,10 @@ namespace XNodeEditor {
|
||||
return tooltip;
|
||||
}
|
||||
|
||||
public virtual string GetNodeTooltip(XNode.Node node) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary> Deal with objects dropped into the graph through DragAndDrop </summary>
|
||||
public virtual void OnDropObjects(UnityEngine.Object[] objects) {
|
||||
if (GetType() != typeof(NodeGraphEditor)) Debug.Log("No OnDropObjects override defined for " + GetType());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user