Esempio n. 1
0
        public override void OnGUI(Rect rect, SerializedProperty property, GUIContent label)
        {
            Type type = property.GetValueType();

            if (type == typeof(FloatRange))
            {
                FloatRangeDrawer.Draw(rect, property, label, true, attribute as ClampAttribute);
            }
            else if (type == typeof(IntRange))
            {
                FloatRangeDrawer.Draw(rect, property, label, false, attribute as ClampAttribute);
            }
            else
            {
                EditorGUI.BeginProperty(rect, label, property);

                EditorGUI.BeginChangeCheck();
                EditorGUI.PropertyField(rect, property, label);

                if (EditorGUI.EndChangeCheck())
                {
                    ClampAttribute clamp = attribute as ClampAttribute;
                    if (property.propertyType == SerializedPropertyType.Float)
                    {
                        property.floatValue = Mathf.Clamp(property.floatValue, clamp.MinFloat, clamp.MaxFloat);
                    }
                    if (property.propertyType == SerializedPropertyType.Integer)
                    {
                        property.intValue = Mathf.Clamp(property.intValue, clamp.MinInt, clamp.MaxInt);
                    }
                }

                EditorGUI.EndProperty();
            }
        }
Esempio n. 2
0
 public override void OnGUI(Rect totalRect, SerializedProperty property, GUIContent label)
 {
     FloatRangeDrawer.Draw(totalRect, property, label, false, null);
 }