8 public class HelpURLFieldDrawer : PropertyDrawer
10 private const float ButtonWidth = 20f;
12 public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
14 var helpURL = (HelpURLFieldAttribute)attribute;
16 var labelWidth = EditorGUIUtility.labelWidth;
17 var labelRect =
new Rect(position.x, position.y, labelWidth, position.height);
19 var fieldRect =
new Rect(position.x + labelWidth + 2f, position.y,
20 position.width - labelWidth - ButtonWidth, position.height);
22 var buttonRect =
new Rect(position.x + labelWidth + fieldRect.width + 3f, position.y, ButtonWidth, position.height);
24 EditorGUI.LabelField(labelRect, label);
25 EditorGUI.PropertyField(fieldRect, property, GUIContent.none);
27 if (GUI.Button(buttonRect,
"?"))
29 Application.OpenURL(helpURL.Url);
33 public override float GetPropertyHeight(SerializedProperty property, GUIContent label) =>
34 EditorGUI.GetPropertyHeight(property, label,
true);
Associates a help URL with a serialized field.