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

!W(Node Editor GUI Layout) LabelAttribute logic

This commit is contained in:
Icarus 2019-12-02 17:59:42 +08:00
parent ecb863630c
commit 32e375e3da

View File

@ -36,10 +36,25 @@ namespace XNodeEditor {
/// <summary> Make a field for a serialized property. Manual node port override. </summary> /// <summary> Make a field for a serialized property. Manual node port override. </summary>
public static void PropertyField(SerializedProperty property, GUIContent label, XNode.NodePort port, bool includeChildren = true, params GUILayoutOption[] options) { 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 == null) throw new NullReferenceException();
// If property is not a port, display a regular property field // If property is not a port, display a regular property field
if (port == null) EditorGUILayout.PropertyField(property, label, includeChildren, GUILayout.MinWidth(30)); if (port == null) EditorGUILayout.PropertyField(property, label, includeChildren, GUILayout.MinWidth(30));
else { 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(); Rect rect = new Rect();
float spacePadding = 0; float spacePadding = 0;