You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
1.1 KiB

  1. using UnityEngine;
  2. using UnityEngine.PostProcessing;
  3. using MinAttribute = UnityEngine.PostProcessing.MinAttribute;
  4. namespace UnityEditor.PostProcessing
  5. {
  6. [CustomPropertyDrawer(typeof(MinAttribute))]
  7. sealed class MinDrawer : PropertyDrawer
  8. {
  9. public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
  10. {
  11. MinAttribute attribute = (MinAttribute)base.attribute;
  12. if (property.propertyType == SerializedPropertyType.Integer)
  13. {
  14. int v = EditorGUI.IntField(position, label, property.intValue);
  15. property.intValue = (int)Mathf.Max(v, attribute.min);
  16. }
  17. else if (property.propertyType == SerializedPropertyType.Float)
  18. {
  19. float v = EditorGUI.FloatField(position, label, property.floatValue);
  20. property.floatValue = Mathf.Max(v, attribute.min);
  21. }
  22. else
  23. {
  24. EditorGUI.LabelField(position, label.text, "Use Min with float or int.");
  25. }
  26. }
  27. }
  28. }