void ShowMethod(Rect rect, MethodDeclaration method) { var label = GetLabel(method); Type type; MethodInfo methodInfo; if (method.Parent == null || (type = TypeUtility.GetType(((TypeDeclaration)method.Parent).GetFullTypeName())) == null || (methodInfo = type.GetMethod(method.Name, method.GetParameterTypes().ToArray())) == null) { EditorGUI.LabelField(rect, label); } else { var buttonStyle = new GUIStyle(EditorStyles.miniButton) { alignment = TextAnchor.MiddleLeft }; rect.y += 1f; rect.width -= 32f; rect.height -= 4f; if (GUI.Button(rect, label, buttonStyle)) { if (methodInfo.IsStatic) methodInfo.Invoke(null, methodInfo.GetDefaultParameters()); else { var instance = Activator.CreateInstance(type); methodInfo.Invoke(instance, methodInfo.GetDefaultParameters()); } } } }