private void drawMethodGUI( int methodIndex, FunctionCallerAttribute attribute, MethodInfo methodInfo ) { GUILayout.Space( 10 ); if( _parameterDetailsDict.Count <= methodIndex ) _parameterDetailsDict.Add( new Dictionary<string,object>() ); var paramDict = _parameterDetailsDict[methodIndex]; // draw the params foreach( var param in methodInfo.GetParameters() ) { var paramKey = param.Name; if( !paramDict.ContainsKey( paramKey ) ) paramDict.Add( paramKey, param.ParameterType.IsValueType ? System.Activator.CreateInstance( param.ParameterType ) : null ); // add any supported types that you want here if( param.ParameterType == typeof( int ) ) paramDict[paramKey] = EditorGUILayout.IntField( paramKey, (int)paramDict[paramKey] ); else if( param.ParameterType == typeof( string ) ) paramDict[paramKey] = EditorGUILayout.TextField( paramKey, (string)paramDict[paramKey] ); } if( GUILayout.Button( attribute.buttonTitle ) ) { var values = new object[paramDict.Count]; paramDict.Values.CopyTo( values, 0 ); methodInfo.Invoke( target, values ); } }
private void drawMethodGUI(int methodIndex, FunctionCallerAttribute attribute, MethodInfo methodInfo) { GUILayout.Space(10); if (_parameterDetailsDict.Count <= methodIndex) { _parameterDetailsDict.Add(new Dictionary <string, object>()); } var paramDict = _parameterDetailsDict[methodIndex]; // draw the params foreach (var param in methodInfo.GetParameters()) { var paramKey = param.Name; if (!paramDict.ContainsKey(paramKey)) { paramDict.Add(paramKey, param.ParameterType.IsValueType ? System.Activator.CreateInstance(param.ParameterType) : null); } // add any supported types that you want here if (param.ParameterType == typeof(int)) { paramDict[paramKey] = EditorGUILayout.IntField(paramKey, (int)paramDict[paramKey]); } else if (param.ParameterType == typeof(string)) { paramDict[paramKey] = EditorGUILayout.TextField(paramKey, (string)paramDict[paramKey]); } } if (GUILayout.Button(attribute.buttonTitle)) { var values = new object[paramDict.Count]; paramDict.Values.CopyTo(values, 0); methodInfo.Invoke(target, values); } }