Skip to main content

Class CurveRangeAttribute

Attribute used to define a visible range for an AnimationCurve field in the Unity Inspector, including optional display color.

[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public class CurveRangeAttribute : PropertyAttribute

Inheritance​

object→Attribute→PropertyAttribute→CurveRangeAttribute

Examples​

Example usage:

public class MyComponent : MonoBehaviour
{
// limit the visual range from (-1, -540f) to (1f, 540f)
[CurveRange(-1f, -540f, 1f, 540f, EColor.Orange)]
public AnimationCurve curve;
}

Constructors​

CurveRangeAttribute(Vector2, Vector2, float, float, float, float)​

Initializes the CurveRange with optional bounds and color.

public CurveRangeAttribute(Vector2 min, Vector2 max, float r = 0, float g = 1, float b = 0, float a = 1)

Parameters​

NameTypeDescription
minVector2The minimum visible range of the curve.
maxVector2The maximum visible range of the curve.
rfloatRed component of color (default 0).
gfloatGreen component of color (default 1).
bfloatBlue component of color (default 0).
afloatAlpha component of color (default 1).

Properties​

Color​

Optional color used to draw the curve background or bounds in the Inspector.

public Color Color { get; }

Property Value​

Color

Max​

The maximum point (x, y) of the curve's visible range.

public Vector2 Max { get; }

Property Value​

Vector2

Min​

The minimum point (x, y) of the curve's visible range.

public Vector2 Min { get; }

Property Value​

Vector2