Skip to content

Commit 8aa34d9

Browse files
author
Antoine Lelievre
committed
Added support of the InspectorName attribute
1 parent e88ef62 commit 8aa34d9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Editor/Views/BaseNodeView.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,13 @@ protected virtual void DrawDefaultInspector(bool fromInspector = false)
712712
showInputDrawer &= !fromInspector; // We can't show a drawer in the inspector
713713
showInputDrawer &= !typeof(IList).IsAssignableFrom(field.FieldType);
714714

715-
var elem = AddControlField(field, ObjectNames.NicifyVariableName(field.Name), showInputDrawer);
715+
string displayName = ObjectNames.NicifyVariableName(field.Name);
716+
717+
var inspectorNameAttribute = field.GetCustomAttribute<InspectorNameAttribute>();
718+
if (inspectorNameAttribute != null)
719+
displayName = inspectorNameAttribute.displayName;
720+
721+
var elem = AddControlField(field, displayName, showInputDrawer);
716722
if (hasInputAttribute)
717723
{
718724
hideElementIfConnected[field.Name] = elem;
@@ -842,7 +848,7 @@ protected VisualElement AddControlField(FieldInfo field, string label = null, bo
842848
element.Bind(owner.serializedGraph);
843849

844850
#if UNITY_2020_3 // In Unity 2020.3 the empty label on property field doesn't hide it, so we do it manually
845-
if (showInputDrawer && element != null)
851+
if ((showInputDrawer || String.IsNullOrEmpty(label)) && element != null)
846852
element.AddToClassList("DrawerField_2020_3");
847853
#endif
848854

0 commit comments

Comments
 (0)