4 namespace HKI.Core.Variables.Editor
9 [CustomPropertyDrawer(typeof(FloatingPointWidthHeight))]
13 const string widthSPName =
"Width";
14 const string heightSPName =
"Height";
16 const float labelWidth = 120.0f;
17 const float widthLabelWidth = 40.0f;
18 const float heightLabelWidth = 45.0f;
21 public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
23 SerializedProperty widthSP =
property.FindPropertyRelative(widthSPName);
24 SerializedProperty heightSP =
property.FindPropertyRelative(heightSPName);
26 float inputFieldWidth = (position.width - labelWidth - widthLabelWidth - heightLabelWidth) / 2.0f;
28 position.width = labelWidth;
29 EditorGUI.LabelField(position, label);
31 position.x += labelWidth;
32 position.width = widthLabelWidth;
33 EditorGUI.LabelField(position, widthSPName);
35 position.x += widthLabelWidth;
36 position.width = inputFieldWidth;
37 EditorGUI.PropertyField(position, widthSP, GUIContent.none);
39 position.x += inputFieldWidth;
40 position.width = heightLabelWidth;
41 EditorGUI.LabelField(position, heightSPName);
43 position.x += heightLabelWidth;
44 position.width = inputFieldWidth;
45 EditorGUI.PropertyField(position, heightSP, GUIContent.none);
Custom property drawer for the FloatingPointWidthHeight class.
override void OnGUI(Rect position, SerializedProperty property, GUIContent label)