Skip to content

Commit 584b1d3

Browse files
committed
Added support of the InspectorName attribute
1 parent 82054cd commit 584b1d3

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

Assets/Examples/DefaultNodes/Nodes/UnityEventNode.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
using System.Collections;
2-
using System.Collections.Generic;
31
using UnityEngine;
42
using GraphProcessor;
5-
using System.Linq;
63
using UnityEngine.Events;
74

85
[System.Serializable, NodeMenuItem("Custom/Unity Event Node")]

Assets/com.alelievr.NodeGraphProcessor/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)