@@ -35,6 +35,9 @@ public partial class MonoFluxEditor : UnityEditor.Editor
3535 private MethodInfo [ ] methods_subscribeAttrb ;
3636 private Dictionary < MethodInfo , object > dic_method_parameters ;
3737 private Dictionary < MethodInfo , object > dic_method_outputs ;
38+ #pragma warning disable CS0618
39+ private Dictionary < MethodInfo , FluxAttribute > dic_method_attributes ;
40+ #pragma warning restore CS0618
3841 private static bool ShowMethods
3942 {
4043 get => PlayerPrefs . GetInt ( "__UniFlux.MonoFluxEditor.ShowBox" , default ) == default ;
@@ -45,7 +48,43 @@ private void OnEnable()
4548 Type type = target . GetType ( ) ;
4649 var methods = type . GetMethods ( ( BindingFlags ) ( - 1 ) ) ;
4750 #pragma warning disable CS0618
48- methods_subscribeAttrb = methods . Where ( m => m . GetCustomAttributes ( typeof ( FluxAttribute ) , true ) . Length > 0 ) . ToArray ( ) ;
51+ var discoveredMethods = new List < MethodInfo > ( ) ;
52+ dic_method_attributes = new Dictionary < MethodInfo , FluxAttribute > ( ) ;
53+
54+ // Phase 1: methods with FluxAttribute on the concrete class
55+ foreach ( var m in methods )
56+ {
57+ if ( Attribute . GetCustomAttributes ( m ) . FirstOrDefault ( a => a is FluxAttribute ) is FluxAttribute attr )
58+ {
59+ discoveredMethods . Add ( m ) ;
60+ dic_method_attributes [ m ] = attr ;
61+ }
62+ }
63+
64+ // Phase 2: FluxAttributes declared on interface method definitions
65+ var interfaces = type . GetInterfaces ( ) ;
66+ for ( int i = 0 ; i < interfaces . Length ; i ++ )
67+ {
68+ var map = type . GetInterfaceMap ( interfaces [ i ] ) ;
69+ for ( int j = 0 ; j < map . InterfaceMethods . Length ; j ++ )
70+ {
71+ var ifaceMethod = map . InterfaceMethods [ j ] ;
72+ if ( Attribute . GetCustomAttributes ( ifaceMethod ) . FirstOrDefault ( a => a is FluxAttribute ) is FluxAttribute attr )
73+ {
74+ var implMethod = map . TargetMethods [ j ] ;
75+ if ( ! dic_method_attributes . ContainsKey ( implMethod ) )
76+ {
77+ dic_method_attributes [ implMethod ] = attr ;
78+ }
79+ if ( ! discoveredMethods . Contains ( implMethod ) )
80+ {
81+ discoveredMethods . Add ( implMethod ) ;
82+ }
83+ }
84+ }
85+ }
86+
87+ methods_subscribeAttrb = discoveredMethods . ToArray ( ) ;
4988 #pragma warning restore CS0618
5089 dic_method_parameters = methods_subscribeAttrb . Select ( m => new { Method = m , Parameters = null as object } ) . ToDictionary ( mp => mp . Method , mp => mp . Parameters ) ;
5190 dic_method_outputs = methods_subscribeAttrb . Select ( m => new { Method = m , Return = null as object } ) . ToDictionary ( mp => mp . Method , mp => mp . Return ) ;
@@ -88,17 +127,15 @@ private void _Draw()
88127 foreach ( var item in methods_subscribeAttrb )
89128 {
90129 #pragma warning disable CS0618
91- var atribute = item . GetCustomAttribute < FluxAttribute > ( ) ;
130+ var atribute = dic_method_attributes [ item ] ;
92131 #pragma warning restore CS0618
93132 var parameters = item . GetParameters ( ) ;
94133 var isParameters = parameters . Length > 0 ;
95134 var isReturn = item . ReturnType != typeof ( void ) ;
96135 var isErr_static = item . IsStatic ;
97136 var isError = isErr_static ;
98137 string key_color = isError ? "yellow" : "white" ;
99- #pragma warning disable CS0618
100- var atrbtype = item . GetCustomAttributes ( typeof ( FluxAttribute ) , true ) [ 0 ] ;
101- #pragma warning restore CS0618
138+ var atrbtype = atribute ;
102139
103140
104141 int opt_status = ( param : isParameters , rtrn : isReturn ) switch
0 commit comments