From 32e375e3da1b185b3103258c9a9172aa0aaa66d1 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Mon, 2 Dec 2019 17:59:42 +0800 Subject: [PATCH] !W(Node Editor GUI Layout) `LabelAttribute` logic --- Scripts/Editor/NodeEditorGUILayout.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Scripts/Editor/NodeEditorGUILayout.cs b/Scripts/Editor/NodeEditorGUILayout.cs index 0a09cc4..857672a 100644 --- a/Scripts/Editor/NodeEditorGUILayout.cs +++ b/Scripts/Editor/NodeEditorGUILayout.cs @@ -36,10 +36,25 @@ namespace XNodeEditor { /// Make a field for a serialized property. Manual node port override. public static void PropertyField(SerializedProperty property, GUIContent label, XNode.NodePort port, bool includeChildren = true, params GUILayoutOption[] options) { if (property == null) throw new NullReferenceException(); - + // If property is not a port, display a regular property field if (port == null) EditorGUILayout.PropertyField(property, label, includeChildren, GUILayout.MinWidth(30)); else { + + Node.LabelAttribute labelAttribute; + + if (NodeEditorUtilities.GetCachedAttrib(port.node.GetType(), property.name, out labelAttribute)) + { + if (label != null) + { + label.text = labelAttribute.Label; + } + else + { + label = new GUIContent(labelAttribute.Label); + } + } + Rect rect = new Rect(); float spacePadding = 0;