@@ -9,11 +9,6 @@ namespace Toolbox.Editor.Drawers
99{
1010 public class EditorButtonAttributeDrawer : ToolboxDecoratorDrawer < EditorButtonAttribute >
1111 {
12- private bool IsCoroutine ( MethodInfo method )
13- {
14- return method . ReturnType == typeof ( IEnumerator ) ;
15- }
16-
1712 private MethodInfo GetMethod ( EditorButtonAttribute attribute , Object [ ] targetObjects , string methodName )
1813 {
1914 var methodInfo = ReflectionUtility . GetObjectMethod ( methodName , targetObjects ) ;
@@ -33,6 +28,11 @@ private MethodInfo GetMethod(EditorButtonAttribute attribute, Object[] targetObj
3328 return methodInfo ;
3429 }
3530
31+ private static bool IsCoroutine ( MethodInfo methodInfo )
32+ {
33+ return methodInfo . ReturnType == typeof ( IEnumerator ) ;
34+ }
35+
3636 private bool IsClickable ( ButtonActivityType activityType )
3737 {
3838 switch ( activityType )
@@ -58,7 +58,7 @@ private bool IsClickable(EditorButtonAttribute attribute, Object[] targetObjects
5858 }
5959
6060 var validateMethodName = attribute . ValidateMethodName ;
61- if ( string . IsNullOrEmpty ( validateMethodName ) )
61+ if ( validateMethodName == null )
6262 {
6363 return true ;
6464 }
@@ -84,8 +84,7 @@ private bool IsClickable(EditorButtonAttribute attribute, Object[] targetObjects
8484 continue ;
8585 }
8686
87- var result = ( bool ) validateMethodInfo . Invoke ( target , null ) ;
88- if ( ! result )
87+ if ( ! ( bool ) validateMethodInfo . Invoke ( target , null ) )
8988 {
9089 return false ;
9190 }
@@ -96,19 +95,9 @@ private bool IsClickable(EditorButtonAttribute attribute, Object[] targetObjects
9695
9796 private void CallMethods ( EditorButtonAttribute attribute , Object [ ] targetObjects )
9897 {
99- var methodInfo = ReflectionUtility . GetObjectMethod ( attribute . MethodName , targetObjects ) ;
100- //validate method name (check if method exists)
98+ var methodInfo = GetMethod ( attribute , targetObjects , attribute . MethodName ) ;
10199 if ( methodInfo == null )
102100 {
103- ToolboxEditorLog . AttributeUsageWarning ( attribute , string . Format ( "{0} method not found." , attribute . MethodName ) ) ;
104- return ;
105- }
106-
107- //validate parameters count and log warning
108- var parameters = methodInfo . GetParameters ( ) ;
109- if ( parameters . Length > 0 )
110- {
111- ToolboxEditorLog . AttributeUsageWarning ( attribute , string . Format ( "{0} method has to be parameterless." , attribute . MethodName ) ) ;
112101 return ;
113102 }
114103
0 commit comments