canto/Assets/Scripts/Editor/PropertyDrawers/DurationPropertyDrawer.cs
2025-07-20 01:20:05 -04:00

34 lines
823 B
C#

using KitsuneCafe.System;
using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
[CustomPropertyDrawer(typeof(Duration))]
public class DurationPropertyDrawer : PropertyDrawer
{
public override VisualElement CreatePropertyGUI(SerializedProperty property)
{
var container = new VisualElement();
container.style.flexDirection = FlexDirection.Row;
var duration = new PropertyField(
property.FindPropertyRelative("displayValue"),
ObjectNames.NicifyVariableName(property.name)
);
duration.style.flexGrow = 1;
var unit = new EnumField
{
bindingPath = "unit"
};
unit.style.flexGrow = 0;
container.Add(duration);
container.Add(unit);
return container;
}
}