using RebootKit.Engine.Foundation; using UnityEditor; using UnityEngine; namespace RebootKit.Editor.PropertyDrawers { [CustomPropertyDrawer(typeof(FloatRange))] public class ValueRangeDrawer : PropertyDrawer { const string k_minPropertyName = "min"; const string k_maxPropertyName = "max"; public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { SerializedProperty minProperty = property.FindPropertyRelative(k_minPropertyName); SerializedProperty maxProperty = property.FindPropertyRelative(k_maxPropertyName); Vector2 minMax = EditorGUILayout.Vector2Field(label, new Vector2(minProperty.floatValue, maxProperty.floatValue)); if (minMax.x > minMax.y) minMax.y = minMax.x; minProperty.floatValue = minMax.x; maxProperty.floatValue = minMax.y; } } }