private void EditButton(ref Rect region, object element, InspectedMethod method) { Rect rect = region; rect.height = ReflectedPropertyEditor.ButtonHeight; string text = method.DisplayName; if (method.HasArguments) { text += " (Remove method parameters to enable this button)"; } EditorGUI.BeginDisabledGroup(method.HasArguments); if (GUI.Button(rect, text)) { method.Invoke(element); } EditorGUI.EndDisabledGroup(); region.y = region.y + (ReflectedPropertyEditor.ButtonHeight + 2f); }
/// <summary> /// A helper method that draws a button at the given region. /// </summary> private void EditButton(ref Rect region, object element, InspectedMethod method) { Rect buttonRect = region; buttonRect.height = ButtonHeight; GUIContent buttonLabel = method.DisplayLabel; // Disable the button if invoking it will cause an exception if (method.HasArguments) { buttonLabel = new GUIContent(buttonLabel); buttonLabel.text += " (Remove method parameters to enable this button)"; } EditorGUI.BeginDisabledGroup(method.HasArguments); if (GUI.Button(buttonRect, buttonLabel)) { method.Invoke(element); } EditorGUI.EndDisabledGroup(); region.y += ButtonHeight; }