AR + GPS Location  3.0.0
All Classes Namespaces Functions Variables Properties Events Pages
OverrideAltitudeDataDrawer.cs
1 using UnityEngine;
2 using UnityEditor;
3 
4 namespace ARLocation
5 {
6  [CustomPropertyDrawer(typeof(OverrideAltitudeData))]
7  public class OverrideAltitudeDataDrawer : PropertyDrawer
8  {
9  public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
10  {
11  EditorGUI.BeginProperty(position, label, property);
12 
13  var initialRect = EditorGUI.IndentedRect(position); //position;
14 
15  position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
16 
17 
18 
19  var indent = EditorGUI.indentLevel;
20  EditorGUI.indentLevel = 0;
21  // EditorGUI.IndentedRect(position);
22 
23  float height = 20.0f;
24 
25  var boolRect = new Rect(position.x, position.y, 30, height);
26  var altitudeRect = new Rect(position.x, position.y + 20, 180, height);
27  var altitudeLabelRect = new Rect(initialRect.x, position.y + height, 50, height);
28 
29  var altitudeModeRect = new Rect(position.x, position.y + (2 * height), 180, height);
30  var altitudeModeLabelRect = new Rect(initialRect.x, position.y + (2 * height), 50, height);
31 
32  EditorGUI.PropertyField(boolRect, property.FindPropertyRelative("OverrideAltitude"), GUIContent.none);
33 
34  if (property.FindPropertyRelative("OverrideAltitude").boolValue)
35  {
36  var x = new GUIContent();
37  var y = new GUIContent();
38  x.text = "Altitude";
39  EditorGUI.PrefixLabel(altitudeLabelRect, x);
40  // EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
41  EditorGUI.PropertyField(altitudeRect, property.FindPropertyRelative("Altitude"), GUIContent.none);
42 
43  y.text = "Altitude Mode";
44  EditorGUI.PrefixLabel(altitudeModeLabelRect, y);
45  EditorGUI.PropertyField(altitudeModeRect, property.FindPropertyRelative("AltitudeMode"), GUIContent.none);
46  }
47 
48  EditorGUI.indentLevel = indent;
49 
50  EditorGUI.EndProperty();
51  }
52 
53  public override float GetPropertyHeight(SerializedProperty property,
54  GUIContent label)
55  {
56  if (property.FindPropertyRelative("OverrideAltitude").boolValue)
57  {
58  return base.GetPropertyHeight(property, label) * 2 + 20;
59  }
60  else
61  {
62  return base.GetPropertyHeight(property, label); // * 2 + 20;
63  }
64  // Height is two times the standard height plus 20 pixels
65  }
66  }
67 }
ARLocation.OverrideAltitudeDataDrawer
Definition: OverrideAltitudeDataDrawer.cs:8
ARLocation
Definition: ARLocationConfigInspector.cs:7