Specify a range of valid values for the field in script properties.
[System.AttributeUsage(System.AttributeTargets.Field)]public class RangeAttribute : AttributeRemarks
Fields with a specified range will show in script properties with both a slider and an editable field. Values will be clamped to be within the range.
Members at a glance
| Kind | Members |
|---|---|
| Constructors | RangeAttribute |
| Properties | Max · Min |
Constructors
RangeAttribute
public RangeAttribute()Specify the allowed range of values for a field using named arguments.
Example
[Range(Min=-10.0, Max=10.0)]public float namedRangeFloat;public RangeAttribute(double min, double max)Specify the allowed range of values for a float or double field.
| Parameter | Type | Description |
|---|---|---|
min | double | The lower bound on the range. Default: 0.0f |
max | double | The upper bound on the range. Default: 0.0f |
Example
[Range(-10.0, 10.0)]public float namedRangeFloat;public RangeAttribute(int min, int max)Specify the allowed range of values for an int field.
| Parameter | Type | Description |
|---|---|---|
min | int | The lower bound on the range. Default: 0 |
max | int | The upper bound on the range. Default: 0 |
Example
[Range(-10, 10)]public int rangeInt;Properties
Max
public object Max { get; set; }Used with default constructor to specify the upper bound on the range.
Value: object — The maximum allowed value for the parameter.
Example
[Range(Min=-10.0, Max=10.0)]public float rangeFloat;Min
public object Min { get; set; }Used with default constructor to specify the lower bound on the range.
Value: object — The minimum allowed value for the parameter.
Example
[Range(Min=-10.0, Max=10.0)]public float rangeFloat;Generated from the Sansar 47.10.0 client ScriptApi snapshot.