From 1b2f94607e31e89abce0d40e28d09d67b4e1e75d Mon Sep 17 00:00:00 2001 From: Thor Brigsted Date: Fri, 2 Feb 2018 12:29:19 +0100 Subject: [PATCH 01/12] Fixed NullRefEx when trying to disconnect a null NodePort --- Scripts/NodePort.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Scripts/NodePort.cs b/Scripts/NodePort.cs index fe9f50d..c017534 100644 --- a/Scripts/NodePort.cs +++ b/Scripts/NodePort.cs @@ -54,8 +54,7 @@ namespace XNode { if (attribs[i] is Node.InputAttribute) { _direction = IO.Input; _connectionType = (attribs[i] as Node.InputAttribute).connectionType; - } - else if (attribs[i] is Node.OutputAttribute) { + } else if (attribs[i] is Node.OutputAttribute) { _direction = IO.Output; _connectionType = (attribs[i] as Node.OutputAttribute).connectionType; } @@ -79,7 +78,7 @@ namespace XNode { _direction = direction; _node = node; _dynamic = true; - _connectionType = connectionType; + _connectionType = connectionType; } /// Checks all connections for invalid references, and removes them. @@ -225,15 +224,17 @@ namespace XNode { connections.RemoveAt(i); } } - // Remove the other ports connection to this port - for (int i = 0; i < port.connections.Count; i++) { - if (port.connections[i].Port == this) { - port.connections.RemoveAt(i); + if (port != null) { + // Remove the other ports connection to this port + for (int i = 0; i < port.connections.Count; i++) { + if (port.connections[i].Port == this) { + port.connections.RemoveAt(i); + } } } // Trigger OnRemoveConnection node.OnRemoveConnection(this); - port.node.OnRemoveConnection(port); + if (port != null) port.node.OnRemoveConnection(port); } public void ClearConnections() { From 57b428761353f18cf94a42391659ef7573afbe83 Mon Sep 17 00:00:00 2001 From: Thor Brigsted Date: Sat, 3 Feb 2018 11:56:20 +0100 Subject: [PATCH 02/12] Fixed ctrl+d duplicate --- Scripts/Editor/NodeEditorAction.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Scripts/Editor/NodeEditorAction.cs b/Scripts/Editor/NodeEditorAction.cs index 946e43a..0019e4c 100644 --- a/Scripts/Editor/NodeEditorAction.cs +++ b/Scripts/Editor/NodeEditorAction.cs @@ -165,9 +165,9 @@ namespace XNodeEditor { isPanning = false; } break; - case EventType.KeyDown: - if (e.keyCode == KeyCode.Delete) RemoveSelectedNodes(); - else if (e.keyCode == KeyCode.D && e.control) DublicateSelectedNodes(); + case EventType.ValidateCommand: + if (e.commandName == "SoftDelete") RemoveSelectedNodes(); + else if (e.commandName == "Duplicate") DublicateSelectedNodes(); Repaint(); break; case EventType.Ignore: From 682dccdd9d734ee9634d64f80d70f9b3b2fb9379 Mon Sep 17 00:00:00 2001 From: Thor Brigsted Date: Mon, 5 Feb 2018 02:07:22 +0100 Subject: [PATCH 03/12] Changed NodeEditorGUILayout labels to use dynamic output GUIStyle based on EditorStyles.label This will make it easier to change node text color Example: [CustomNodeEditor(typeof(MyNode))] public class MyNodeEditor : NodeEditor { private static GUIStyle editorLabelStyle; public override void OnBodyGUI() { if (editorLabelStyle == null) editorLabelStyle = new GUIStyle(EditorStyles.label); EditorStyles.label.normal.textColor = Color.green; base.OnBodyGUI(); EditorStyles.label.normal = editorLabelStyle.normal; } } --- Scripts/Editor/NodeEditorGUILayout.cs | 4 ++-- Scripts/Editor/NodeEditorResources.cs | 11 ++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Scripts/Editor/NodeEditorGUILayout.cs b/Scripts/Editor/NodeEditorGUILayout.cs index 0a377f9..d173abf 100644 --- a/Scripts/Editor/NodeEditorGUILayout.cs +++ b/Scripts/Editor/NodeEditorGUILayout.cs @@ -70,13 +70,13 @@ namespace XNodeEditor { switch (showBacking) { case XNode.Node.ShowBackingValue.Unconnected: // Display a label if port is connected - if (port.IsConnected) EditorGUILayout.LabelField(label != null ? label : new GUIContent(property.displayName), NodeEditorResources.styles.outputPort, GUILayout.MinWidth(30)); + if (port.IsConnected) EditorGUILayout.LabelField(label != null ? label : new GUIContent(property.displayName), NodeEditorResources.OutputPort, GUILayout.MinWidth(30)); // Display an editable property field if port is not connected else EditorGUILayout.PropertyField(property, label, includeChildren, GUILayout.MinWidth(30)); break; case XNode.Node.ShowBackingValue.Never: // Display a label - EditorGUILayout.LabelField(label != null ? label : new GUIContent(property.displayName), NodeEditorResources.styles.outputPort, GUILayout.MinWidth(30)); + EditorGUILayout.LabelField(label != null ? label : new GUIContent(property.displayName), NodeEditorResources.OutputPort, GUILayout.MinWidth(30)); break; case XNode.Node.ShowBackingValue.Always: // Display an editable property field diff --git a/Scripts/Editor/NodeEditorResources.cs b/Scripts/Editor/NodeEditorResources.cs index 9b55c8f..0a84e0a 100644 --- a/Scripts/Editor/NodeEditorResources.cs +++ b/Scripts/Editor/NodeEditorResources.cs @@ -1,4 +1,5 @@ -using UnityEngine; +using UnityEditor; +using UnityEngine; namespace XNodeEditor { public static class NodeEditorResources { @@ -15,9 +16,9 @@ namespace XNodeEditor { // Styles public static Styles styles { get { return _styles != null ? _styles : _styles = new Styles(); } } public static Styles _styles = null; - + public static GUIStyle OutputPort { get { return new GUIStyle(EditorStyles.label) { alignment = TextAnchor.UpperRight }; } } public class Styles { - public GUIStyle inputPort, outputPort, nodeHeader, nodeBody, tooltip, nodeHighlight; + public GUIStyle inputPort, nodeHeader, nodeBody, tooltip, nodeHighlight; public Styles() { GUIStyle baseStyle = new GUIStyle("Label"); @@ -27,10 +28,6 @@ namespace XNodeEditor { inputPort.alignment = TextAnchor.UpperLeft; inputPort.padding.left = 10; - outputPort = new GUIStyle(baseStyle); - outputPort.alignment = TextAnchor.UpperRight; - outputPort.padding.right = 10; - nodeHeader = new GUIStyle(); nodeHeader.alignment = TextAnchor.MiddleCenter; nodeHeader.fontStyle = FontStyle.Bold; From 71cde080b6df8a300d8460365f3e818112c91732 Mon Sep 17 00:00:00 2001 From: Thor Brigsted Date: Mon, 5 Feb 2018 03:12:50 +0100 Subject: [PATCH 04/12] Revert "Performance improvement. (removed unnecessary override)" This reverts commit 51e77a227956dd043b6a6b7b19ef440a10518909. --- Scripts/Node.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Scripts/Node.cs b/Scripts/Node.cs index 0e0449f..ddc43ea 100644 --- a/Scripts/Node.cs +++ b/Scripts/Node.cs @@ -202,6 +202,10 @@ namespace XNode { foreach (NodePort port in Ports) port.ClearConnections(); } + public override int GetHashCode() { + return JsonUtility.ToJson(this).GetHashCode(); + } + /// Mark a serializable field as an input port. You can access this through [AttributeUsage(AttributeTargets.Field, AllowMultiple = true)] public class InputAttribute : Attribute { From 4c773ad5cfe5268a73222d4966667d7d5460e68c Mon Sep 17 00:00:00 2001 From: Thor Brigsted Date: Wed, 7 Feb 2018 12:30:11 +0100 Subject: [PATCH 05/12] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 5194a63..e64c6c0 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,6 @@ With a minimal footprint, it is ideal as a base for custom state machines, dialo * No runtime reflection (unless you need to edit/build node graphs at runtime. In this case, all reflection is cached.) * Does not rely on any 3rd party plugins * Custom node inspector code is very similar to regular custom inspector code -* For a full list of features, see [this page](https://github.com/Siccity/xNode/wiki/Full-features-list) ### Node example: ```csharp From 1ff815c627dea327742a6221d111834ece28612d Mon Sep 17 00:00:00 2001 From: Thor Brigsted Date: Wed, 7 Feb 2018 12:32:09 +0100 Subject: [PATCH 06/12] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e64c6c0..e9db741 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/Siccity/xNode/master/LICENSE.md) [![GitHub Wiki](https://img.shields.io/badge/wiki-available-brightgreen.svg)](https://github.com/Siccity/xNode/wiki) -[Go to Downloads](https://github.com/Siccity/xNode/releases) / [Go to Asset Store](http://u3d.as/108S) +[Downloads](https://github.com/Siccity/xNode/releases) / [Asset Store](http://u3d.as/108S) / [Documentation](https://github.com/Siccity/xNode/wiki) ### xNode Thinking of developing a node-based plugin? Then this is for you. You can download it as an archive and unpack to a new unity project, or connect it as git submodule. From b787b57eb33f8dcf651bcc7968cb1ddd518210f2 Mon Sep 17 00:00:00 2001 From: Thor Brigsted Date: Wed, 7 Feb 2018 18:17:37 +0100 Subject: [PATCH 07/12] Revert "Minor performance improvement (cachine serialized objects)" This reverts commit dba4cd18429d0d2800d7391708f96da037ba8ce9. --- Scripts/Editor/NodeEditorBase.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/Scripts/Editor/NodeEditorBase.cs b/Scripts/Editor/NodeEditorBase.cs index 0868ce0..14ef5ce 100644 --- a/Scripts/Editor/NodeEditorBase.cs +++ b/Scripts/Editor/NodeEditorBase.cs @@ -10,7 +10,6 @@ namespace XNodeEditor.Internal { public class NodeEditorBase where A : Attribute, NodeEditorBase.INodeEditorAttrib where T : NodeEditorBase where K : ScriptableObject { /// Custom editors defined with [CustomNodeEditor] private static Dictionary editors; - private static Dictionary serializeds; public K target; public SerializedObject serializedObject; @@ -19,17 +18,10 @@ namespace XNodeEditor.Internal { Type type = target.GetType(); T editor = GetEditor(type); editor.target = target; - editor.serializedObject = GetSerialized(target); + editor.serializedObject = new SerializedObject(target); return editor; } - private static SerializedObject GetSerialized(K target) { - if (target == null) return null; - if (serializeds == null) serializeds = new Dictionary(); - if (!serializeds.ContainsKey(target)) serializeds.Add(target, new SerializedObject(target)); - return serializeds[target]; - } - private static T GetEditor(Type type) { if (type == null) return null; if (editors == null) CacheCustomEditors(); From 2a951a3002aa7a7136a62bcc2754e16009223157 Mon Sep 17 00:00:00 2001 From: Thor Brigsted Date: Fri, 9 Feb 2018 14:29:18 +0100 Subject: [PATCH 08/12] Fixed Connection returning null when non-nulls exist. --- Scripts/NodePort.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Scripts/NodePort.cs b/Scripts/NodePort.cs index c017534..b609066 100644 --- a/Scripts/NodePort.cs +++ b/Scripts/NodePort.cs @@ -9,8 +9,15 @@ namespace XNode { public enum IO { Input, Output } public int ConnectionCount { get { return connections.Count; } } - /// Return the first connection - public NodePort Connection { get { return connections.Count > 0 ? connections[0].Port : null; } } + /// Return the first non-null connection + public NodePort Connection { + get { + for (int i = 0; i < connections.Count; i++) { + if (connections[i] != null) return connections[i].Port; + } + return null; + } + } public IO direction { get { return _direction; } } public Node.ConnectionType connectionType { get { return _connectionType; } } From 7985055bc75d52a979b9de550ac60204308cf981 Mon Sep 17 00:00:00 2001 From: Thor Brigsted Date: Tue, 13 Feb 2018 11:06:03 +0100 Subject: [PATCH 09/12] Create CONTRIBUTING.md Read this before contributing --- CONTRIBUTING.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..b96a660 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,23 @@ +## Contributing to xNode +💙Thank you for taking the time to contribute💙 + +If you haven't already, join our [Discord channel](https://discord.gg/qgPrHv4)! + +## Pull Requests +Try to keep your pull requests relevant, neat, and manageable. If you are adding multiple features, try splitting them into separate commits. +* Avoid including irellevant whitespace or formatting changes. +* Comment your code. +* Spell check your code / comments + +## New features +xNode aims to be simple and extendible, not trying to fix all of Unity's shortcomings. + +If your feature aims to cover something not related to editing nodes, it generally won't be accepted. If in doubt, ask on the Discord channel. + +## Coding conventions +Skim through the code and you'll get the hang of it quickly. +* Methods, Types and properties PascalCase +* Variables camelCase +* Public methods XML commented +* Open braces on same line as condition +* 4 spaces for indentation. From 5ef958f298f42762c929d2f377d3282d156c19e6 Mon Sep 17 00:00:00 2001 From: Thor Brigsted Date: Mon, 19 Feb 2018 17:09:59 +0100 Subject: [PATCH 10/12] Added c# script templates Create > xNode > Node/NodeGraph --- Scripts/Editor/NodeEditorUtilities.cs | 89 +++++++++++++++++++ Scripts/Editor/Resources/ScriptTemplates.meta | 10 +++ .../xNode_NodeGraphTemplate.cs.txt | 9 ++ .../xNode_NodeGraphTemplate.cs.txt.meta | 9 ++ .../ScriptTemplates/xNode_NodeTemplate.cs.txt | 18 ++++ .../xNode_NodeTemplate.cs.txt.meta | 9 ++ 6 files changed, 144 insertions(+) create mode 100644 Scripts/Editor/Resources/ScriptTemplates.meta create mode 100644 Scripts/Editor/Resources/ScriptTemplates/xNode_NodeGraphTemplate.cs.txt create mode 100644 Scripts/Editor/Resources/ScriptTemplates/xNode_NodeGraphTemplate.cs.txt.meta create mode 100644 Scripts/Editor/Resources/ScriptTemplates/xNode_NodeTemplate.cs.txt create mode 100644 Scripts/Editor/Resources/ScriptTemplates/xNode_NodeTemplate.cs.txt.meta diff --git a/Scripts/Editor/NodeEditorUtilities.cs b/Scripts/Editor/NodeEditorUtilities.cs index d0cbc7b..0d98420 100644 --- a/Scripts/Editor/NodeEditorUtilities.cs +++ b/Scripts/Editor/NodeEditorUtilities.cs @@ -1,12 +1,20 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Reflection; +using System.Text; +using UnityEditor; +using UnityEngine; +using Object = UnityEngine.Object; namespace XNodeEditor { /// A set of editor-only utilities and extensions for UnityNodeEditorBase public static class NodeEditorUtilities { + /// C#'s Script Icon [The one MonoBhevaiour Scripts have]. + private static Texture2D scriptIcon = (EditorGUIUtility.IconContent("cs Script Icon").image as Texture2D); + public static bool GetAttrib(Type classType, out T attribOut) where T : Attribute { object[] attribs = classType.GetCustomAttributes(typeof(T), false); return GetAttrib(attribs, out attribOut); @@ -85,5 +93,86 @@ namespace XNodeEditor { } } else return type.ToString(); } + + /// Creates a new C# Class. + [MenuItem("Assets/Create/xNode/Node C# Script", false, 89)] + private static void CreateNode() { + string[] guids = AssetDatabase.FindAssets("xNode_NodeTemplate.cs"); + if (guids.Length == 0) { + Debug.LogWarning("xNode_NodeTemplate.cs.txt not found in asset database"); + return; + } + string path = AssetDatabase.GUIDToAssetPath(guids[0]); + CreateFromTemplate( + "NewNode.cs", + path + ); + } + + /// Creates a new C# Class. + [MenuItem("Assets/Create/xNode/NodeGraph C# Script", false, 89)] + private static void CreateGraph() { + string[] guids = AssetDatabase.FindAssets("xNode_NodeGraphTemplate.cs"); + if (guids.Length == 0) { + Debug.LogWarning("xNode_NodeGraphTemplate.cs.txt not found in asset database"); + return; + } + string path = AssetDatabase.GUIDToAssetPath(guids[0]); + CreateFromTemplate( + "NewNodeGraph.cs", + path + ); + } + + public static void CreateFromTemplate(string initialName, string templatePath) { + ProjectWindowUtil.StartNameEditingIfProjectWindowExists( + 0, + ScriptableObject.CreateInstance(), + initialName, + scriptIcon, + templatePath + ); + } + + /// Inherits from EndNameAction, must override EndNameAction.Action + public class DoCreateCodeFile : UnityEditor.ProjectWindowCallback.EndNameEditAction { + public override void Action(int instanceId, string pathName, string resourceFile) { + Object o = CreateScript(pathName, resourceFile); + ProjectWindowUtil.ShowCreatedAsset(o); + } + } + + /// Creates Script from Template's path. + internal static UnityEngine.Object CreateScript(string pathName, string templatePath) { + string className = Path.GetFileNameWithoutExtension(pathName).Replace(" ", string.Empty); + string templateText = string.Empty; + + UTF8Encoding encoding = new UTF8Encoding(true, false); + + if (File.Exists(templatePath)) { + /// Read procedures. + StreamReader reader = new StreamReader(templatePath); + templateText = reader.ReadToEnd(); + reader.Close(); + + templateText = templateText.Replace("#SCRIPTNAME#", className); + templateText = templateText.Replace("#NOTRIM#", string.Empty); + /// You can replace as many tags you make on your templates, just repeat Replace function + /// e.g.: + /// templateText = templateText.Replace("#NEWTAG#", "MyText"); + + /// Write procedures. + + StreamWriter writer = new StreamWriter(Path.GetFullPath(pathName), false, encoding); + writer.Write(templateText); + writer.Close(); + + AssetDatabase.ImportAsset(pathName); + return AssetDatabase.LoadAssetAtPath(pathName, typeof(Object)); + } else { + Debug.LogError(string.Format("The template file was not found: {0}", templatePath)); + return null; + } + } } } \ No newline at end of file diff --git a/Scripts/Editor/Resources/ScriptTemplates.meta b/Scripts/Editor/Resources/ScriptTemplates.meta new file mode 100644 index 0000000..b2435e8 --- /dev/null +++ b/Scripts/Editor/Resources/ScriptTemplates.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 86b677955452bb5449f9f4dd47b6ddfe +folderAsset: yes +timeCreated: 1519049391 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/Resources/ScriptTemplates/xNode_NodeGraphTemplate.cs.txt b/Scripts/Editor/Resources/ScriptTemplates/xNode_NodeGraphTemplate.cs.txt new file mode 100644 index 0000000..e3d7c36 --- /dev/null +++ b/Scripts/Editor/Resources/ScriptTemplates/xNode_NodeGraphTemplate.cs.txt @@ -0,0 +1,9 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using XNode; + +[CreateAssetMenu] +public class #SCRIPTNAME# : NodeGraph { + #NOTRIM# +} \ No newline at end of file diff --git a/Scripts/Editor/Resources/ScriptTemplates/xNode_NodeGraphTemplate.cs.txt.meta b/Scripts/Editor/Resources/ScriptTemplates/xNode_NodeGraphTemplate.cs.txt.meta new file mode 100644 index 0000000..b55bd75 --- /dev/null +++ b/Scripts/Editor/Resources/ScriptTemplates/xNode_NodeGraphTemplate.cs.txt.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 8165767f64da7d94e925f61a38da668c +timeCreated: 1519049802 +licenseType: Free +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/Resources/ScriptTemplates/xNode_NodeTemplate.cs.txt b/Scripts/Editor/Resources/ScriptTemplates/xNode_NodeTemplate.cs.txt new file mode 100644 index 0000000..de791fc --- /dev/null +++ b/Scripts/Editor/Resources/ScriptTemplates/xNode_NodeTemplate.cs.txt @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using XNode; + +public class #SCRIPTNAME# : Node { + + // Use this for initialization + protected override void Init() { + base.Init(); + #NOTRIM# + } + + // Return the correct value of an output port when requested + public override object GetValue(NodePort port) { + return null; // Replace this + } +} \ No newline at end of file diff --git a/Scripts/Editor/Resources/ScriptTemplates/xNode_NodeTemplate.cs.txt.meta b/Scripts/Editor/Resources/ScriptTemplates/xNode_NodeTemplate.cs.txt.meta new file mode 100644 index 0000000..455420a --- /dev/null +++ b/Scripts/Editor/Resources/ScriptTemplates/xNode_NodeTemplate.cs.txt.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 85f6f570600a1a44d8e734cb111a8b89 +timeCreated: 1519049802 +licenseType: Free +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: From ed2edab72f64167c9da2ac9cbdcc5da2ddd8b810 Mon Sep 17 00:00:00 2001 From: Thor Brigsted Date: Wed, 21 Mar 2018 22:00:28 +0100 Subject: [PATCH 11/12] Added F for "Home" hotkey --- Scripts/Editor/NodeEditorAction.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Scripts/Editor/NodeEditorAction.cs b/Scripts/Editor/NodeEditorAction.cs index 0019e4c..7b43574 100644 --- a/Scripts/Editor/NodeEditorAction.cs +++ b/Scripts/Editor/NodeEditorAction.cs @@ -140,8 +140,12 @@ namespace XNodeEditor { } else if (!IsHoveringNode) { // If click outside node, release field focus if (!isPanning) { + // I've got no idea which of these do what, so we'll just reset all of it. GUIUtility.hotControl = 0; GUIUtility.keyboardControl = 0; + EditorGUIUtility.editingTextField = false; + EditorGUIUtility.keyboardControl = 0; + EditorGUIUtility.hotControl = 0; } AssetDatabase.SaveAssets(); } @@ -165,6 +169,10 @@ namespace XNodeEditor { isPanning = false; } break; + case EventType.KeyDown: + if (EditorGUIUtility.editingTextField) break; + else if (e.keyCode == KeyCode.F) Home(); + break; case EventType.ValidateCommand: if (e.commandName == "SoftDelete") RemoveSelectedNodes(); else if (e.commandName == "Duplicate") DublicateSelectedNodes(); From 219c93557d4918d31744484dfab046747b2a611d Mon Sep 17 00:00:00 2001 From: Thor Brigsted Date: Thu, 22 Mar 2018 23:25:51 +0100 Subject: [PATCH 12/12] Tooltip now shows value from GetValue instead of field variable --- Scripts/Editor/NodeEditorGUI.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Scripts/Editor/NodeEditorGUI.cs b/Scripts/Editor/NodeEditorGUI.cs index 2843151..4db162b 100644 --- a/Scripts/Editor/NodeEditorGUI.cs +++ b/Scripts/Editor/NodeEditorGUI.cs @@ -364,8 +364,8 @@ namespace XNodeEditor { GUIContent content = new GUIContent(); content.text = type.PrettyName(); if (hoveredPort.IsStatic && hoveredPort.IsOutput) { - object obj = ObjectFromFieldName(hoveredPort.node, hoveredPort.fieldName); - if (obj != null) content.text += " = " + obj.ToString(); + object obj = hoveredPort.node.GetValue(hoveredPort); + content.text += " = " + (obj != null ? obj.ToString() : "null"); } Vector2 size = NodeEditorResources.styles.tooltip.CalcSize(content); Rect rect = new Rect(Event.current.mousePosition - (size), size);