module-inspector/Editor/ValueModifiers/DrawerSmallerThanField.cs

17 lines
658 B
C#

using UnityEditor;
namespace Module.Inspector.Editor
{
[CustomPropertyDrawer(typeof(SmallerThanField))]
internal sealed class DrawerSmallerThanField : ValueModifierPropertyDrawer
{
public override void Modify(ValueModifierPropertyAttribute attribute, SerializedProperty property)
{
var att = (SmallerThanField)attribute;
SerializedPropertyExtension.ECompareType compareType = property.IsSmallerOrEqualToSiblingValue(att.fieldName);
if (compareType == SerializedPropertyExtension.ECompareType.False)
property.SetValueTo(property.GetSibling(att.fieldName));
}
}
}