RangeAttribute

RangeAttribute Class

Specify a range of valid values for the field in script properties.

Syntax

[System.AttributeUsage(System.AttributeTargets.Field)]
public class RangeAttribute : Attribute

Remarks

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.

Requirements

Namespace: Sansar.Script
Assembly: Sansar.Script (in Sansar.Script.dll)
Assembly Versions: 1.0.0.0

Members

See Also: Inherited members from Attribute.

Public Constructors

 
Specify the allowed range of values for a field using named arguments.
 
Specify the allowed range of values for a float or double field.
 
Specify the allowed range of values for an int field.

Public Properties

 
Max object . Used with default constructor to specify the upper bound on the range.
 
Min object . Used with default constructor to specify the lower bound on the range.

Member Details

RangeAttribute Constructor

Specify the allowed range of values for a field using named arguments.

Syntax

public RangeAttribute ()

Remarks

 

Example

C# Example
            [Range(Min=-10.0, Max=10.0)]
            public float namedRangeFloat;
            

Requirements

Namespace: Sansar.Script
Assembly: Sansar.Script (in Sansar.Script.dll)
Assembly Versions: 1.0.0.0

RangeAttribute Constructor

Specify the allowed range of values for a float or double field.

Syntax

public RangeAttribute (double min, double max)

Parameters

min
The lower bound on the range. Default: 0.0f
max
The upper bound on the range. Default: 0.0f

Remarks

 

Example

C# Example
            [Range(-10.0, 10.0)]
            public float namedRangeFloat;
            

Requirements

Namespace: Sansar.Script
Assembly: Sansar.Script (in Sansar.Script.dll)
Assembly Versions: 1.0.0.0

RangeAttribute Constructor

Specify the allowed range of values for an int field.

Syntax

public RangeAttribute (int min, int max)

Parameters

min
The lower bound on the range. Default: 0
max
The upper bound on the range. Default: 0

Remarks

 

Example

C# Example
            [Range(-10, 10)]
            public int rangeInt;
            

Requirements

Namespace: Sansar.Script
Assembly: Sansar.Script (in Sansar.Script.dll)
Assembly Versions: 1.0.0.0

Max Property

Used with default constructor to specify the upper bound on the range.

Syntax

public object Max { get; set; }

Value

The maximum allowed value for the parameter.

Remarks

 

Example

C# Example
            [Range(Min=-10.0, Max=10.0)]
            public float rangeFloat;
            

Requirements

Namespace: Sansar.Script
Assembly: Sansar.Script (in Sansar.Script.dll)
Assembly Versions: 1.0.0.0

Min Property

Used with default constructor to specify the lower bound on the range.

Syntax

public object Min { get; set; }

Value

The minimum allowed value for the parameter.

Remarks

 

Example

C# Example
            [Range(Min=-10.0, Max=10.0)]
            public float rangeFloat;
            

Requirements

Namespace: Sansar.Script
Assembly: Sansar.Script (in Sansar.Script.dll)
Assembly Versions: 1.0.0.0


Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Article is closed for comments.