Space Ad Mobile 9.5.1
Space Ad Mobile makes ads easy to add into your mobile game: one unified workflow for LevelPlay, AdMob, Yandex.Ads across banners, interstitials and rewarded.
Loading...
Searching...
No Matches
HelpURLFieldDrawer.cs
1#if UNITY_EDITOR
2using UnityEditor;
3using UnityEngine;
4
5namespace SCG.SpaceAdMobile
6{
7 [CustomPropertyDrawer(typeof(HelpURLFieldAttribute))]
8 public class HelpURLFieldDrawer : PropertyDrawer
9 {
10 private const float ButtonWidth = 20f;
11
12 public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
13 {
14 var helpURL = (HelpURLFieldAttribute)attribute;
15
16 var labelWidth = EditorGUIUtility.labelWidth;
17 var labelRect = new Rect(position.x, position.y, labelWidth, position.height);
18
19 var fieldRect = new Rect(position.x + labelWidth + 2f, position.y,
20 position.width - labelWidth - ButtonWidth, position.height);
21
22 var buttonRect = new Rect(position.x + labelWidth + fieldRect.width + 3f, position.y, ButtonWidth, position.height);
23
24 EditorGUI.LabelField(labelRect, label);
25 EditorGUI.PropertyField(fieldRect, property, GUIContent.none);
26
27 if (GUI.Button(buttonRect, "?"))
28 {
29 Application.OpenURL(helpURL.Url);
30 }
31 }
32
33 public override float GetPropertyHeight(SerializedProperty property, GUIContent label) =>
34 EditorGUI.GetPropertyHeight(property, label, true);
35 }
36}
37#endif
Associates a help URL with a serialized field.