mirror of
https://github.com/maxartz15/VolumetricLighting.git
synced 2024-11-10 01:02:55 +01:00
24 lines
681 B
C#
24 lines
681 B
C#
|
using UnityEngine;
|
|||
|
using UnityEditor;
|
|||
|
|
|||
|
[CustomPropertyDrawer (typeof (MinValueAttribute))]
|
|||
|
public class MinValueDrawer : PropertyDrawer {
|
|||
|
|
|||
|
public override void OnGUI (Rect position, SerializedProperty property, GUIContent label)
|
|||
|
{
|
|||
|
if (property.propertyType != SerializedPropertyType.Float && property.propertyType != SerializedPropertyType.Integer)
|
|||
|
{
|
|||
|
EditorGUI.LabelField (position, label.text, "Use MinValue with float or int.");
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
EditorGUI.PropertyField(position, property, label);
|
|||
|
|
|||
|
if (GUI.changed)
|
|||
|
{
|
|||
|
MinValueAttribute minValue = attribute as MinValueAttribute;
|
|||
|
property.floatValue = Mathf.Max(property.floatValue, minValue.min);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|