Odin has a dedicated attribute overview with examples

MaxValueAttribute class

Namespace: Sirenix.OdinInspector
Assembly: Sirenix.OdinInspector.Attributes
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.Delegate | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter | AttributeTargets.All, AllowMultiple = false, Inherited = true)]
public sealed class MaxValueAttribute : Attribute, _Attribute

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.

  • System.Object
  • System.Attribute
  • MaxValueAttribute


Note that this attribute only works in the editor! Values changed from scripting will not be capped at a maximum.


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.
	public float Speed;

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;


Sets a maximum value for the property in the inspector.
public MaxValueAttribute(double maxValue)
System.Double maxValue

The max value.


The maximum value for the property.
public double MaxValue

This website is brand new and built with the Odin 2.1 beta in mind. This means you might discover some features such as attribute expressions that are only available in the beta.

You can download the 2.1 beta from here and read the patch-notes here.