Description
The Max
property of the RangeAttribute
class specifies the maximum allowable value for a property that is marked with this attribute. This is typically used in conjunction with the Min
property to define a range of valid values, often visualized as a slider in the inspector.
Usage
Use the Max
property to set the upper limit of a range for a property. This is particularly useful when you want to restrict the values that can be assigned to a property, ensuring they fall within a specified range. This can help prevent errors and ensure that values remain within expected bounds.
Example
// Example of using RangeAttribute with Max property
[Range(Min = 0.0f, Max = 100.0f, Step = 1.0f, Slider = true)]
public float Health { get; set; }