13using System.Collections.Generic;
37 public void DrawProperty(Rect rect, SerializedProperty property, GUIContent label) {
38 EditorGUI.BeginProperty(rect, label, property);
40 Vector2 value =
property.vector2Value;
42 rect = EditorGUI.PrefixLabel(rect, GUIUtility.GetControlID(FocusType.Passive), label);
44 int prevIndent = EditorGUI.indentLevel;
45 EditorGUI.indentLevel = 0;
49 Rect leftNum =
new Rect(rect.x, rect.y, w, rect.height);
50 Rect slider =
new Rect(rect.x + w +
SPACING, rect.y, rect.width - 2 * w -
SPACING * 2, rect.height);
51 Rect rightNum =
new Rect(rect.x + rect.width - w, rect.y, w, rect.height);
53 float newMin = EditorGUI.FloatField(leftNum, value.x);
54 float newMax = EditorGUI.FloatField(rightNum, value.y);
56 value.x = Mathf.Clamp(newMin,
min, value.y);
57 value.y = Mathf.Clamp(newMax, value.x,
max);
59 EditorGUI.MinMaxSlider(slider, ref value.x, ref value.y,
min,
max);
61 property.vector2Value = value;
63 EditorGUI.EndProperty();
65 EditorGUI.indentLevel = prevIndent;
68 public override IEnumerable<SerializedPropertyType> SupportedTypes {
70 yield
return SerializedPropertyType.Vector2;
MinMax(float min, float max)