Class RoundedValueCurveAttribute
Attribute that can be applied to AnimationCurve fields to round all keyframe values to the nearest integer. Optionally enforces constant tangents for smoother stepped transitions.
public class RoundedValueCurveAttribute : PropertyAttribute
Inheritance
Examples
This example shows how to round all values of a curve field to the nearest integer and enforce step-like tangents:
[RoundedValueCurve(constantTangents: true)]
public AnimationCurve healthThresholds;
Remarks
This attribute is useful for curves that drive integer-based logic (e.g., state IDs, enum-like transitions, or step-based animations) where precise floating-point values are unnecessary or problematic.
When ConstantTangents is set to true, the drawer will also enforce constant tangents
on all keyframes, effectively creating a step function between points instead of interpolated curves.
In the Inspector, any changes to the curve will result in:
- Keyframe values being rounded to whole numbers.
- Tangents being set to constant (flat) to produce discrete jumps.
Constructors
RoundedValueCurveAttribute(bool)
Creates a new RoundedValueCurveAttribute instance.
public RoundedValueCurveAttribute(bool constantTangents = false)
Parameters
| Name | Type | Description |
|---|---|---|
constantTangents | bool | If true, sets all key tangents to constant (flat), producing a step-like curve. Defaults to false. |