mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 09:16:01 +08:00
Fixed #144 - Added virtual GetPortTooltip in NodeGraphEditor
This commit is contained in:
parent
95884080b0
commit
d0e1cd5d66
@ -441,14 +441,10 @@ namespace XNodeEditor {
|
||||
}
|
||||
|
||||
private void DrawTooltip() {
|
||||
if (hoveredPort != null && NodeEditorPreferences.GetSettings().portTooltips) {
|
||||
Type type = hoveredPort.ValueType;
|
||||
GUIContent content = new GUIContent();
|
||||
content.text = type.PrettyName();
|
||||
if (hoveredPort.IsOutput) {
|
||||
object obj = hoveredPort.node.GetValue(hoveredPort);
|
||||
content.text += " = " + (obj != null ? obj.ToString() : "null");
|
||||
}
|
||||
if (hoveredPort != null && NodeEditorPreferences.GetSettings().portTooltips && graphEditor != null) {
|
||||
string tooltip = graphEditor.GetPortTooltip(hoveredPort);
|
||||
if (string.IsNullOrEmpty(tooltip)) return;
|
||||
GUIContent content = new GUIContent(tooltip);
|
||||
Vector2 size = NodeEditorResources.styles.tooltip.CalcSize(content);
|
||||
Rect rect = new Rect(Event.current.mousePosition - (size), size);
|
||||
EditorGUI.LabelField(rect, content, NodeEditorResources.styles.tooltip);
|
||||
|
||||
@ -70,6 +70,17 @@ namespace XNodeEditor {
|
||||
return NodeEditorPreferences.GetTypeColor(type);
|
||||
}
|
||||
|
||||
public virtual string GetPortTooltip(XNode.NodePort port) {
|
||||
Type portType = port.ValueType;
|
||||
string tooltip = "";
|
||||
tooltip = portType.PrettyName();
|
||||
if (port.IsOutput) {
|
||||
object obj = port.node.GetValue(port);
|
||||
tooltip += " = " + (obj != null ? obj.ToString() : "null");
|
||||
}
|
||||
return tooltip;
|
||||
}
|
||||
|
||||
/// <summary> Deal with objects dropped into the graph through DragAndDrop </summary>
|
||||
public virtual void OnDropObjects(UnityEngine.Object[] objects) {
|
||||
Debug.Log("No OnDropItems override defined for " + GetType());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user