MaxValueAttribute

MaxValue is used on primitive fields. It caps value of the field to a maximum value.

Use this to define a maximum value for the field.

namespace Sirenix.OdinInspector
{
[AttributeUsageAttribute((AttributeTargets)384, AllowMultiple = False, Inherited = True)]
public sealed class MaxValueAttribute : Attribute
}

Requirements

Namespace: Sirenix.OdinInspector
Assembly: Sirenix.OdinInspector
Version: 1.0.5.0

See Also

Constructors

Definition Description
MaxValueAttribute(double) Sets a maximum value for the property in the inspector.

Properties

Return Type Definition Description
double MaxValue The maximum value for the property.

Example

The following example shows a component where a speed value must be less than or equal to 200.

public class Car : MonoBehaviour
{
	// The speed of the car must be less than or equal to 200.
	[MaxValue(200)]
	public float Speed;
}

Example

The following example shows how MaxValue can be combined with MinValueAttribute.

public class Health : MonoBehaviour
{
	// The speed value must be between 0 and 200.
	[MinValue(0), MaxValue(200)]
	public float Speed;
}