MinValueAttribute

MinValue is used on primitive fields. It caps value of the field to a minimum value.

Use this to define a minimum value for the field.

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

Requirements

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

See Also

Constructors

Definition Description
MinValueAttribute(double) Sets a minimum value for the property in the inspector.

Properties

Return Type Definition Description
double MinValue The minimum value for the property.

Example

The following example shows a player component that must have at least 1 life.

public class Player : MonoBehaviour
{
	// The life value must be set to at least 1.
	[MinValue(1)]
	public int Life;
}

Example

The following example shows how MinValue can be combined with MaxValueAttribute

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