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)]
[Conditional("UNITY_EDITOR")]
public sealed class MinValueAttribute : Attribute, _Attribute
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.
Note that this attribute only works in the editor! Values changed from scripting will not be capped at a minimum.
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;
}
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;
}
public MinValueAttribute(double minValue)
System.Double | minValue | The minimum value. |
public MinValueAttribute(string expression)
System.String | expression | The string with which to resolve a minimum value. This could be a field, property or method name, or an expression. |
public string Expression
public double MinValue