@@ -40,7 +40,7 @@ public class BaseNodeView : NodeView
4040 public event Action < PortView > onPortConnected ;
4141 public event Action < PortView > onPortDisconnected ;
4242
43- protected virtual bool hasSettings => false ;
43+ protected virtual bool hasSettings { get ; set ; }
4444
4545 public bool initializing = false ; //Used for applying SetPosition on locked node at init.
4646
@@ -173,7 +173,12 @@ void InitializeSettings()
173173 settings . Add ( CreateSettingsView ( ) ) ;
174174 settingsContainer . Add ( settings ) ;
175175 Add ( settingsContainer ) ;
176+
177+ var fields = nodeTarget . GetType ( ) . GetFields ( BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Instance | BindingFlags . DeclaredOnly ) ;
176178
179+ foreach ( var field in fields )
180+ if ( field . GetCustomAttribute ( typeof ( SettingAttribute ) ) != null )
181+ AddSettingField ( field ) ;
177182 }
178183 }
179184
@@ -555,6 +560,13 @@ protected virtual void DrawDefaultInspector(bool fromInspector = false)
555560
556561 foreach ( var field in fields )
557562 {
563+ //skip if the field is a node setting
564+ if ( field . GetCustomAttribute ( typeof ( SettingAttribute ) ) != null )
565+ {
566+ hasSettings = true ;
567+ continue ;
568+ }
569+
558570 //skip if the field is not serializable
559571 if ( ! field . IsPublic && field . GetCustomAttribute ( typeof ( SerializeField ) ) == null )
560572 {
@@ -736,6 +748,25 @@ void UpdateFieldValues()
736748 foreach ( var kp in fieldControlsMap )
737749 UpdateOtherFieldValue ( kp . Key , kp . Key . GetValue ( nodeTarget ) ) ;
738750 }
751+
752+ protected void AddSettingField ( FieldInfo field )
753+ {
754+ if ( field == null )
755+ return ;
756+
757+ var label = field . GetCustomAttribute < SettingAttribute > ( ) . name ;
758+
759+ var element = FieldFactory . CreateField ( field . FieldType , field . GetValue ( nodeTarget ) , ( newValue ) => {
760+ owner . RegisterCompleteObjectUndo ( "Updated " + newValue ) ;
761+ field . SetValue ( nodeTarget , newValue ) ;
762+ } , label ) ;
763+
764+ if ( element != null )
765+ {
766+ settingsContainer . Add ( element ) ;
767+ element . name = field . Name ;
768+ }
769+ }
739770
740771 internal void OnPortConnected ( PortView port )
741772 {
@@ -972,7 +1003,7 @@ void UpdatePortsForField(string fieldName)
9721003 RefreshPorts ( ) ;
9731004 }
9741005
975- protected virtual VisualElement CreateSettingsView ( ) => new Label ( "Settings" ) ;
1006+ protected virtual VisualElement CreateSettingsView ( ) => new Label ( "Settings" ) { name = "header" } ;
9761007
9771008 /// <summary>
9781009 /// Send an event to the graph telling that the content of this node have changed
0 commit comments