broken
This commit is contained in:
23
Editor/PropertyDrawers/ValueRangeDrawer.cs
Normal file
23
Editor/PropertyDrawers/ValueRangeDrawer.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using RebootKit.Engine.Foundation;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RebootKitEditor.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user