module-inspector/Editor/ValueModifiers/LargerThanFieldAttributeDrawer.cs

17 lines
682 B
C#

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