예제 #1
0
        protected override void OnGUI_Internal(Rect rect, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(rect, label, property);

            // Check user error
            if (property.propertyType != SerializedPropertyType.AnimationCurve)
            {
                string message = string.Format("Field {0} is not an AnimationCurve", property.name);
                DrawDefaultPropertyAndHelpBox(rect, property, message, MessageType.Warning);
                return;
            }

            if (_cachedCurveRangeAttribute == null)
            {
                _cachedCurveRangeAttribute = PropertyUtility.GetAttribute <CurveRangeAttribute>(property);
            }

            var attribute = _cachedCurveRangeAttribute;

            EditorGUI.CurveField(
                rect,
                property,
                attribute.Color == EColor.Clear ? Color.green : attribute.Color.GetColor(),
                new Rect(attribute.Min.x, attribute.Min.y, attribute.Max.x - attribute.Min.x, attribute.Max.y - attribute.Min.y),
                label);

            EditorGUI.EndProperty();
        }
예제 #2
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        CurveRangeAttribute curveRange = attribute as CurveRangeAttribute;

        EditorGUI.BeginProperty(position, label, property);
        if (property.propertyType != SerializedPropertyType.AnimationCurve)
        {
            EditorGUI.HelpBox(position, string.Format("{0} is not an AnimationCurve but has [CurveRange].", property.name), MessageType.Error);
        }
        else
        {
            property.animationCurveValue = EditorGUI.CurveField(position, property.displayName, property.animationCurveValue, curveRange.Color, curveRange.Ranges);
        }
        EditorGUI.EndProperty();
    }