# RangeAttribute

Kind: Class · Namespace: Sansar.Script · Assembly: Sansar.Script.dll · Script API 47.10.0

<div class="api-meta">
<span class="api-kind api-kind-class" data-pagefind-filter="kind:Class">Class</span>
<span data-pagefind-filter="namespace:Sansar.Script">Namespace <a href="/scripting/api/sansar.script"><code>Sansar.Script</code></a></span>
<span>Inherits <a href="https://learn.microsoft.com/dotnet/api/system.attribute">Attribute</a></span>
</div>

<span id="T:Sansar.Script.RangeAttribute"></span>

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

```csharp
[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.

## Members at a glance

| Kind | Members |
|---|---|
| **Constructors** | [RangeAttribute](#rangeattribute) |
| **Properties** | [Max](#max) · [Min](#min) |

## Constructors

### RangeAttribute

<div class="api-card" id="ctor">
<span id="M:Sansar.Script.RangeAttribute.#ctor"></span>
<span id="C:Sansar.Script.RangeAttribute()"></span>

```csharp signature
public RangeAttribute()
```

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

<details class="api-example" open><summary>Example</summary>

```csharp
[Range(Min=-10.0, Max=10.0)]
public float namedRangeFloat;
```

</details>

</div>

<div class="api-card" id="ctor-double-double">
<span id="M:Sansar.Script.RangeAttribute.#ctor(System.Double,System.Double)"></span>
<span id="C:Sansar.Script.RangeAttribute(System.Double,System.Double)"></span>

```csharp signature
public RangeAttribute(double min, double max)
```

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

| Parameter | Type | Description |
|---|---|---|
| `min` | [double](https://learn.microsoft.com/dotnet/api/system.double) | The lower bound on the range. Default: 0.0f |
| `max` | [double](https://learn.microsoft.com/dotnet/api/system.double) | The upper bound on the range. Default: 0.0f |

<details class="api-example" open><summary>Example</summary>

```csharp
[Range(-10.0, 10.0)]
public float namedRangeFloat;
```

</details>

</div>

<div class="api-card" id="ctor-int32-int32">
<span id="M:Sansar.Script.RangeAttribute.#ctor(System.Int32,System.Int32)"></span>
<span id="C:Sansar.Script.RangeAttribute(System.Int32,System.Int32)"></span>

```csharp signature
public RangeAttribute(int min, int max)
```

Specify the allowed range of values for an int field.

| Parameter | Type | Description |
|---|---|---|
| `min` | [int](https://learn.microsoft.com/dotnet/api/system.int32) | The lower bound on the range. Default: 0 |
| `max` | [int](https://learn.microsoft.com/dotnet/api/system.int32) | The upper bound on the range. Default: 0 |

<details class="api-example" open><summary>Example</summary>

```csharp
[Range(-10, 10)]
public int rangeInt;
```

</details>

</div>


## Properties

### Max

<div class="api-card">
<span id="P:Sansar.Script.RangeAttribute.Max"></span>

```csharp signature
public object Max { get; set; }
```

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

**Value:** [object](https://learn.microsoft.com/dotnet/api/system.object) — The maximum allowed value for the parameter.

<details class="api-example" open><summary>Example</summary>

```csharp
[Range(Min=-10.0, Max=10.0)]
public float rangeFloat;
```

</details>

</div>

### Min

<div class="api-card">
<span id="P:Sansar.Script.RangeAttribute.Min"></span>

```csharp signature
public object Min { get; set; }
```

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

**Value:** [object](https://learn.microsoft.com/dotnet/api/system.object) — The minimum allowed value for the parameter.

<details class="api-example" open><summary>Example</summary>

```csharp
[Range(Min=-10.0, Max=10.0)]
public float rangeFloat;
```

</details>

</div>




<p class="api-generated" data-pagefind-ignore>Generated from the Sansar 47.10.0 client ScriptApi snapshot.</p>