# LightComponent

Kind: Class · Namespace: Sansar.Simulation · Assembly: Sansar.Simulation.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.Simulation">Namespace <a href="/scripting/api/sansar.simulation"><code>Sansar.Simulation</code></a></span>
<span>Inherits <a href="/scripting/api/sansar.script/instanceinterface">Sansar.Script.InstanceInterface</a></span>
</div>

<span id="T:Sansar.Simulation.LightComponent"></span>

The LightComponent handles interactions with lights.

```csharp
public class LightComponent : Sansar.Script.InstanceInterface
```

## Members at a glance

| Kind | Members |
|---|---|
| **Fields** | [ComponentType](#componenttype) |
| **Properties** | [ComponentId](#componentid) · [IsScriptable](#isscriptable) · [LightType](#lighttype) · [Name](#name) |
| **Methods** | [GetAngle](#getangle) · [GetAngularFalloff](#getangularfalloff) · [GetCastsShadows](#getcastsshadows) · [GetNearClip](#getnearclip) · [GetNormalizedColor](#getnormalizedcolor) · [GetRange](#getrange) · [GetRelativeIntensity](#getrelativeintensity) · [GetShadowPriority](#getshadowpriority) · [SetAngle](#setangle) · [SetAngularFalloff](#setangularfalloff) · [SetCastsShadows](#setcastsshadows) · [SetColorAndIntensity](#setcolorandintensity) · [SetNearClip](#setnearclip) · [SetRange](#setrange) · [SetShadowPriority](#setshadowpriority) · [ToString](#tostring) |

## Fields

### ComponentType

<div class="api-card">
<span id="F:Sansar.Simulation.LightComponent.ComponentType"></span>

```csharp signature
public static readonly ComponentType ComponentType
```

The [`LightComponent.ComponentType`](/scripting/api/sansar.simulation/lightcomponent#componenttype) of this component

</div>


## Properties

### ComponentId

<div class="api-card">
<span id="P:Sansar.Simulation.LightComponent.ComponentId"></span>

```csharp signature
public Sansar.Script.ComponentId ComponentId { get; }
```

Retrieves the component id for this LightComponent.

**Value:** [Sansar.Script.ComponentId](/scripting/api/sansar.script/componentid) — The id.

</div>

### IsScriptable

<div class="api-card">
<span id="P:Sansar.Simulation.LightComponent.IsScriptable"></span>

```csharp signature
public bool IsScriptable { get; }
```

The scriptable flag for this LightComponent.

**Value:** [bool](https://learn.microsoft.com/dotnet/api/system.boolean) — Whether or not this light can have properties changed by script.

</div>

### LightType

<div class="api-card">
<span id="P:Sansar.Simulation.LightComponent.LightType"></span>

```csharp signature
public LightType LightType { get; }
```

The light type for this LightComponent.

**Value:** [LightType](/scripting/api/sansar.simulation/lighttype) — Light type enum for the light component.

</div>

### Name

<div class="api-card">
<span id="P:Sansar.Simulation.LightComponent.Name"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 33.2.0</span></div>

```csharp signature
public string Name { get; }
```

This LightComponent name, as specified in the editor.

</div>


## Methods

### GetAngle

<div class="api-card">
<span id="M:Sansar.Simulation.LightComponent.GetAngle"></span>
<span id="M:Sansar.Simulation.LightComponent.GetAngle()"></span>

```csharp signature
public float GetAngle()
```

Retrieves the cone angle of this LightComponent.

**Returns:** [float](https://learn.microsoft.com/dotnet/api/system.single) — The angle in degrees.

</div>

### GetAngularFalloff

<div class="api-card">
<span id="M:Sansar.Simulation.LightComponent.GetAngularFalloff"></span>
<span id="M:Sansar.Simulation.LightComponent.GetAngularFalloff()"></span>

```csharp signature
public float GetAngularFalloff()
```

Retrieves the angular falloff of this LightComponent.

**Returns:** [float](https://learn.microsoft.com/dotnet/api/system.single) — The angular falloff.

</div>

### GetCastsShadows

<div class="api-card">
<span id="M:Sansar.Simulation.LightComponent.GetCastsShadows"></span>
<span id="M:Sansar.Simulation.LightComponent.GetCastsShadows()"></span>

```csharp signature
public bool GetCastsShadows()
```

Retrieves whether this LightComponent casts shadows.

**Returns:** [bool](https://learn.microsoft.com/dotnet/api/system.boolean) — The shadow cast state.

</div>

### GetNearClip

<div class="api-card">
<span id="M:Sansar.Simulation.LightComponent.GetNearClip"></span>
<span id="M:Sansar.Simulation.LightComponent.GetNearClip()"></span>

```csharp signature
public float GetNearClip()
```

Retrieves the near clip distance of this LightComponent.

**Returns:** [float](https://learn.microsoft.com/dotnet/api/system.single) — The near clip distance.

</div>

### GetNormalizedColor

<div class="api-card">
<span id="M:Sansar.Simulation.LightComponent.GetNormalizedColor"></span>
<span id="M:Sansar.Simulation.LightComponent.GetNormalizedColor()"></span>

```csharp signature
public Sansar.Color GetNormalizedColor()
```

Retrieves the normalized color of this LightComponent.

**Returns:** [Sansar.Color](/scripting/api/sansar/color) — The normalized color.

<details class="api-remarks"><summary>Remarks</summary>

This might not match values set via script or in the editor since the color of a light is internally multiplied by its intensity before being applied to the scene.

</details>

</div>

### GetRange

<div class="api-card">
<span id="M:Sansar.Simulation.LightComponent.GetRange"></span>
<span id="M:Sansar.Simulation.LightComponent.GetRange()"></span>

```csharp signature
public float GetRange()
```

Retrieves the current range of this LightComponent.

**Returns:** [float](https://learn.microsoft.com/dotnet/api/system.single) — The range.

</div>

### GetRelativeIntensity

<div class="api-card">
<span id="M:Sansar.Simulation.LightComponent.GetRelativeIntensity"></span>
<span id="M:Sansar.Simulation.LightComponent.GetRelativeIntensity()"></span>

```csharp signature
public float GetRelativeIntensity()
```

Retrieves the intensity of this LightComponent based on its normalized color.

**Returns:** [float](https://learn.microsoft.com/dotnet/api/system.single) — The intensity based on a normalized color.

<details class="api-remarks"><summary>Remarks</summary>

This might not match values set via script or in the editor since the color of a light is internally multiplied by its intensity before being applied to the scene.

</details>

</div>

### GetShadowPriority

<div class="api-card">
<span id="M:Sansar.Simulation.LightComponent.GetShadowPriority"></span>
<span id="M:Sansar.Simulation.LightComponent.GetShadowPriority()"></span>

```csharp signature
public uint GetShadowPriority()
```

Retrieves the shadow priority of this LightComponent.

**Returns:** [uint](https://learn.microsoft.com/dotnet/api/system.uint32) — The shadow priority.

</div>

### SetAngle

<div class="api-card" id="setangle-single">
<span id="M:Sansar.Simulation.LightComponent.SetAngle(System.Single)"></span>

```csharp signature
public void SetAngle(float angle)
```

Sets the cone angle for this LightComponent of type LightType.SpotLight.

| Parameter | Type | Description |
|---|---|---|
| `angle` | [float](https://learn.microsoft.com/dotnet/api/system.single) | The angle in degrees, 1 to 160. |

<details class="api-remarks"><summary>Remarks</summary>

This method only affects spot lights. This asynchronous method queues the write then returns. To block until the write has occurred, pass this method to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor) while in a coroutine.

</details>

</div>

<div class="api-card" id="setangle-single-operationcomplete">
<span id="M:Sansar.Simulation.LightComponent.SetAngle(System.Single,Sansar.Script.ScriptBase.OperationComplete)"></span>
<div class="api-badges"><span class="api-badge api-deprecated">Deprecated</span></div>

```csharp signature
[System.Obsolete("Deprecated. Use the Action<> overload", false)]
public ulong SetAngle(
    float angle,
    Sansar.Script.ScriptBase.OperationComplete handler
)
```

Sets the cone angle for this LightComponent of type LightType.SpotLight.

| Parameter | Type | Description |
|---|---|---|
| `angle` | [float](https://learn.microsoft.com/dotnet/api/system.single) | The angle in degrees, 1 to 160. |
| `handler` | [Sansar.Script.ScriptBase.OperationComplete](/scripting/api/sansar.script/scriptbase.operationcomplete) | Handler to be called when the event completes. |

**Returns:** [ulong](https://learn.microsoft.com/dotnet/api/system.uint64) — The return value is an internal event id.

<details class="api-remarks"><summary>Remarks</summary>

This method only affects spot lights. This asynchronous method queues the write then returns. To block until the write has occurred, pass this method to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor) while in a coroutine.

</details>

</div>

<div class="api-card" id="setangle-single-action">
<span id="M:Sansar.Simulation.LightComponent.SetAngle(System.Single,System.Action{Sansar.Script.OperationCompleteEvent})"></span>

```csharp signature
public void SetAngle(
    float angle,
    Action<Sansar.Script.OperationCompleteEvent> handler
)
```

Sets the cone angle for this LightComponent of type LightType.SpotLight.

| Parameter | Type | Description |
|---|---|---|
| `angle` | [float](https://learn.microsoft.com/dotnet/api/system.single) | The angle in degrees, 1 to 160. |
| `handler` | [Action&lt;Sansar.Script.OperationCompleteEvent&gt;](https://learn.microsoft.com/dotnet/api/system.action-1) | Handler to be called when the event completes. |

<details class="api-remarks"><summary>Remarks</summary>

This method only affects spot lights. This asynchronous method queues the write then returns. To block until the write has occurred, pass this method to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor) while in a coroutine.

</details>

</div>

### SetAngularFalloff

<div class="api-card" id="setangularfalloff-single">
<span id="M:Sansar.Simulation.LightComponent.SetAngularFalloff(System.Single)"></span>

```csharp signature
public void SetAngularFalloff(float angularFalloff)
```

Sets the angular falloff for this LightComponent of type LightType.SpotLight.

| Parameter | Type | Description |
|---|---|---|
| `angularFalloff` | [float](https://learn.microsoft.com/dotnet/api/system.single) | The angular falloff, 0.01 to 1. |

<details class="api-remarks"><summary>Remarks</summary>

This method only affects spot lights. This asynchronous method queues the write then returns. To block until the write has occurred, pass this method to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor) while in a coroutine.

</details>

</div>

<div class="api-card" id="setangularfalloff-single-operationcomplete">
<span id="M:Sansar.Simulation.LightComponent.SetAngularFalloff(System.Single,Sansar.Script.ScriptBase.OperationComplete)"></span>
<div class="api-badges"><span class="api-badge api-deprecated">Deprecated</span></div>

```csharp signature
[System.Obsolete("Deprecated. Use the Action<> overload", false)]
public ulong SetAngularFalloff(
    float angularFalloff,
    Sansar.Script.ScriptBase.OperationComplete handler
)
```

Sets the angular falloff for this LightComponent of type LightType.SpotLight.

| Parameter | Type | Description |
|---|---|---|
| `angularFalloff` | [float](https://learn.microsoft.com/dotnet/api/system.single) | The angular falloff, 0.01 to 1. |
| `handler` | [Sansar.Script.ScriptBase.OperationComplete](/scripting/api/sansar.script/scriptbase.operationcomplete) | Handler to be called when the event completes. |

**Returns:** [ulong](https://learn.microsoft.com/dotnet/api/system.uint64) — The return value is an internal event id.

<details class="api-remarks"><summary>Remarks</summary>

This method only affects spot lights. This asynchronous method queues the write then returns. To block until the write has occurred, pass this method to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor) while in a coroutine.

</details>

</div>

<div class="api-card" id="setangularfalloff-single-action">
<span id="M:Sansar.Simulation.LightComponent.SetAngularFalloff(System.Single,System.Action{Sansar.Script.OperationCompleteEvent})"></span>

```csharp signature
public void SetAngularFalloff(
    float angularFalloff,
    Action<Sansar.Script.OperationCompleteEvent> handler
)
```

Sets the angular falloff for this LightComponent of type LightType.SpotLight.

| Parameter | Type | Description |
|---|---|---|
| `angularFalloff` | [float](https://learn.microsoft.com/dotnet/api/system.single) | The angular falloff, 0.01 to 1. |
| `handler` | [Action&lt;Sansar.Script.OperationCompleteEvent&gt;](https://learn.microsoft.com/dotnet/api/system.action-1) | Handler to be called when the event completes. |

<details class="api-remarks"><summary>Remarks</summary>

This method only affects spot lights. This asynchronous method queues the write then returns. To block until the write has occurred, pass this method to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor) while in a coroutine.

</details>

</div>

### SetCastsShadows

<div class="api-card" id="setcastsshadows-boolean">
<span id="M:Sansar.Simulation.LightComponent.SetCastsShadows(System.Boolean)"></span>

```csharp signature
public void SetCastsShadows(bool castsShadows)
```

Sets whether shadows are cast from this LightComponent of type LightType.SpotLight.

| Parameter | Type | Description |
|---|---|---|
| `castsShadows` | [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | True to cast shadows. |

<details class="api-remarks"><summary>Remarks</summary>

This method only affects spot lights. This asynchronous method queues the write then returns. To block until the write has occurred, pass this method to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor) while in a coroutine.

</details>

</div>

<div class="api-card" id="setcastsshadows-boolean-operationcomplete">
<span id="M:Sansar.Simulation.LightComponent.SetCastsShadows(System.Boolean,Sansar.Script.ScriptBase.OperationComplete)"></span>
<div class="api-badges"><span class="api-badge api-deprecated">Deprecated</span></div>

```csharp signature
[System.Obsolete("Deprecated. Use the Action<> overload", false)]
public ulong SetCastsShadows(
    bool castsShadows,
    Sansar.Script.ScriptBase.OperationComplete handler
)
```

Sets whether shadows are cast from this LightComponent of type LightType.SpotLight.

| Parameter | Type | Description |
|---|---|---|
| `castsShadows` | [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | True to cast shadows. |
| `handler` | [Sansar.Script.ScriptBase.OperationComplete](/scripting/api/sansar.script/scriptbase.operationcomplete) | Handler to be called when the event completes. |

**Returns:** [ulong](https://learn.microsoft.com/dotnet/api/system.uint64) — The return value is an internal event id.

<details class="api-remarks"><summary>Remarks</summary>

This method only affects spot lights. This asynchronous method queues the write then returns. To block until the write has occurred, pass this method to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor) while in a coroutine.

</details>

</div>

<div class="api-card" id="setcastsshadows-boolean-action">
<span id="M:Sansar.Simulation.LightComponent.SetCastsShadows(System.Boolean,System.Action{Sansar.Script.OperationCompleteEvent})"></span>

```csharp signature
public void SetCastsShadows(
    bool castsShadows,
    Action<Sansar.Script.OperationCompleteEvent> handler
)
```

Sets whether shadows are cast from this LightComponent of type LightType.SpotLight.

| Parameter | Type | Description |
|---|---|---|
| `castsShadows` | [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | True to cast shadows. |
| `handler` | [Action&lt;Sansar.Script.OperationCompleteEvent&gt;](https://learn.microsoft.com/dotnet/api/system.action-1) | Handler to be called when the event completes. |

<details class="api-remarks"><summary>Remarks</summary>

This method only affects spot lights. This asynchronous method queues the write then returns. To block until the write has occurred, pass this method to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor) while in a coroutine.

</details>

</div>

### SetColorAndIntensity

<div class="api-card" id="setcolorandintensity-color-single">
<span id="M:Sansar.Simulation.LightComponent.SetColorAndIntensity(Sansar.Color,System.Single)"></span>

```csharp signature
public void SetColorAndIntensity(Sansar.Color color, float intensity)
```

Sets the color for this LightComponent.

| Parameter | Type | Description |
|---|---|---|
| `color` | [Sansar.Color](/scripting/api/sansar/color) | The color. |
| `intensity` | [float](https://learn.microsoft.com/dotnet/api/system.single) | The intensity, 0 to 100. |

<details class="api-remarks"><summary>Remarks</summary>

The intensity is multiplied by the color and then applied to the light. This asynchronous method queues the write then returns. To block until the write has occurred, pass this method to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor) while in a coroutine.

</details>

</div>

<div class="api-card" id="setcolorandintensity-color-single-operationcomplete">
<span id="M:Sansar.Simulation.LightComponent.SetColorAndIntensity(Sansar.Color,System.Single,Sansar.Script.ScriptBase.OperationComplete)"></span>
<div class="api-badges"><span class="api-badge api-deprecated">Deprecated</span></div>

```csharp signature
[System.Obsolete("Deprecated. Use the Action<> overload", false)]
public ulong SetColorAndIntensity(
    Sansar.Color color,
    float intensity,
    Sansar.Script.ScriptBase.OperationComplete handler
)
```

Sets the color for this LightComponent.

| Parameter | Type | Description |
|---|---|---|
| `color` | [Sansar.Color](/scripting/api/sansar/color) | The color. |
| `intensity` | [float](https://learn.microsoft.com/dotnet/api/system.single) | The intensity, 0 to 100. |
| `handler` | [Sansar.Script.ScriptBase.OperationComplete](/scripting/api/sansar.script/scriptbase.operationcomplete) | Handler to be called when the event completes. |

**Returns:** [ulong](https://learn.microsoft.com/dotnet/api/system.uint64) — The return value is an internal event id.

<details class="api-remarks"><summary>Remarks</summary>

The intensity is multiplied by the color and then applied to the light. This asynchronous method queues the write then returns. To block until the write has occurred, pass this method to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor) while in a coroutine.

</details>

</div>

<div class="api-card" id="setcolorandintensity-color-single-action">
<span id="M:Sansar.Simulation.LightComponent.SetColorAndIntensity(Sansar.Color,System.Single,System.Action{Sansar.Script.OperationCompleteEvent})"></span>

```csharp signature
public void SetColorAndIntensity(
    Sansar.Color color,
    float intensity,
    Action<Sansar.Script.OperationCompleteEvent> handler
)
```

Sets the color for this LightComponent.

| Parameter | Type | Description |
|---|---|---|
| `color` | [Sansar.Color](/scripting/api/sansar/color) | The color. |
| `intensity` | [float](https://learn.microsoft.com/dotnet/api/system.single) | The intensity, 0 to 100. |
| `handler` | [Action&lt;Sansar.Script.OperationCompleteEvent&gt;](https://learn.microsoft.com/dotnet/api/system.action-1) | Handler to be called when the event completes. |

<details class="api-remarks"><summary>Remarks</summary>

The intensity is multiplied by the color and then applied to the light. This asynchronous method queues the write then returns. To block until the write has occurred, pass this method to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor) while in a coroutine.

</details>

</div>

### SetNearClip

<div class="api-card" id="setnearclip-single">
<span id="M:Sansar.Simulation.LightComponent.SetNearClip(System.Single)"></span>

```csharp signature
public void SetNearClip(float nearClip)
```

Sets the near clip plane distance for this LightComponent of type LightType.SpotLight.

| Parameter | Type | Description |
|---|---|---|
| `nearClip` | [float](https://learn.microsoft.com/dotnet/api/system.single) | The near clip distance, 0 to 500. |

<details class="api-remarks"><summary>Remarks</summary>

This method only affects spot lights. This asynchronous method queues the write then returns. To block until the write has occurred, pass this method to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor) while in a coroutine.

</details>

</div>

<div class="api-card" id="setnearclip-single-operationcomplete">
<span id="M:Sansar.Simulation.LightComponent.SetNearClip(System.Single,Sansar.Script.ScriptBase.OperationComplete)"></span>
<div class="api-badges"><span class="api-badge api-deprecated">Deprecated</span></div>

```csharp signature
[System.Obsolete("Deprecated. Use the Action<> overload", false)]
public ulong SetNearClip(
    float nearClip,
    Sansar.Script.ScriptBase.OperationComplete handler
)
```

Sets the near clip plane distance for this LightComponent of type LightType.SpotLight.

| Parameter | Type | Description |
|---|---|---|
| `nearClip` | [float](https://learn.microsoft.com/dotnet/api/system.single) | The near clip distance, 0 to 500. |
| `handler` | [Sansar.Script.ScriptBase.OperationComplete](/scripting/api/sansar.script/scriptbase.operationcomplete) | Handler to be called when the event completes. |

**Returns:** [ulong](https://learn.microsoft.com/dotnet/api/system.uint64) — The return value is an internal event id.

<details class="api-remarks"><summary>Remarks</summary>

This method only affects spot lights. This asynchronous method queues the write then returns. To block until the write has occurred, pass this method to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor) while in a coroutine.

</details>

</div>

<div class="api-card" id="setnearclip-single-action">
<span id="M:Sansar.Simulation.LightComponent.SetNearClip(System.Single,System.Action{Sansar.Script.OperationCompleteEvent})"></span>

```csharp signature
public void SetNearClip(
    float nearClip,
    Action<Sansar.Script.OperationCompleteEvent> handler
)
```

Sets the near clip plane distance for this LightComponent of type LightType.SpotLight.

| Parameter | Type | Description |
|---|---|---|
| `nearClip` | [float](https://learn.microsoft.com/dotnet/api/system.single) | The near clip distance, 0 to 500. |
| `handler` | [Action&lt;Sansar.Script.OperationCompleteEvent&gt;](https://learn.microsoft.com/dotnet/api/system.action-1) | Handler to be called when the event completes. |

<details class="api-remarks"><summary>Remarks</summary>

This method only affects spot lights. This asynchronous method queues the write then returns. To block until the write has occurred, pass this method to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor) while in a coroutine.

</details>

</div>

### SetRange

<div class="api-card" id="setrange-single">
<span id="M:Sansar.Simulation.LightComponent.SetRange(System.Single)"></span>

```csharp signature
public void SetRange(float range)
```

Sets the range for this LightComponent.

| Parameter | Type | Description |
|---|---|---|
| `range` | [float](https://learn.microsoft.com/dotnet/api/system.single) | The range, 1 to 500. |

<details class="api-remarks"><summary>Remarks</summary>

This asynchronous method queues the write then returns. To block until the write has occurred, pass this method to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor) while in a coroutine.

</details>

</div>

<div class="api-card" id="setrange-single-operationcomplete">
<span id="M:Sansar.Simulation.LightComponent.SetRange(System.Single,Sansar.Script.ScriptBase.OperationComplete)"></span>
<div class="api-badges"><span class="api-badge api-deprecated">Deprecated</span></div>

```csharp signature
[System.Obsolete("Deprecated. Use the Action<> overload", false)]
public ulong SetRange(
    float range,
    Sansar.Script.ScriptBase.OperationComplete handler
)
```

Sets the range for this LightComponent.

| Parameter | Type | Description |
|---|---|---|
| `range` | [float](https://learn.microsoft.com/dotnet/api/system.single) | The range, 1 to 500. |
| `handler` | [Sansar.Script.ScriptBase.OperationComplete](/scripting/api/sansar.script/scriptbase.operationcomplete) | Handler to be called when the event completes. |

**Returns:** [ulong](https://learn.microsoft.com/dotnet/api/system.uint64) — The return value is an internal event id.

<details class="api-remarks"><summary>Remarks</summary>

This asynchronous method queues the write then returns. To block until the write has occurred, pass this method to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor) while in a coroutine.

</details>

</div>

<div class="api-card" id="setrange-single-action">
<span id="M:Sansar.Simulation.LightComponent.SetRange(System.Single,System.Action{Sansar.Script.OperationCompleteEvent})"></span>

```csharp signature
public void SetRange(
    float range,
    Action<Sansar.Script.OperationCompleteEvent> handler
)
```

Sets the range for this LightComponent.

| Parameter | Type | Description |
|---|---|---|
| `range` | [float](https://learn.microsoft.com/dotnet/api/system.single) | The range, 1 to 500. |
| `handler` | [Action&lt;Sansar.Script.OperationCompleteEvent&gt;](https://learn.microsoft.com/dotnet/api/system.action-1) | Handler to be called when the event completes. |

<details class="api-remarks"><summary>Remarks</summary>

This asynchronous method queues the write then returns. To block until the write has occurred, pass this method to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor) while in a coroutine.

</details>

</div>

### SetShadowPriority

<div class="api-card" id="setshadowpriority-uint32">
<span id="M:Sansar.Simulation.LightComponent.SetShadowPriority(System.UInt32)"></span>

```csharp signature
public void SetShadowPriority(uint shadowPriority)
```

Sets the shadow priority of this LightComponent of type LightType.SpotLight.

| Parameter | Type | Description |
|---|---|---|
| `shadowPriority` | [uint](https://learn.microsoft.com/dotnet/api/system.uint32) | Shadow priority. |

<details class="api-remarks"><summary>Remarks</summary>

Set this to zero to turn off shadows. This method only affects spot lights. The renderer prioritizes shadows cast from higher priority lights first. This asynchronous method queues the write then returns. To block until the write has occurred, pass this method to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor) while in a coroutine.

</details>

</div>

<div class="api-card" id="setshadowpriority-uint32-operationcomplete">
<span id="M:Sansar.Simulation.LightComponent.SetShadowPriority(System.UInt32,Sansar.Script.ScriptBase.OperationComplete)"></span>
<div class="api-badges"><span class="api-badge api-deprecated">Deprecated</span></div>

```csharp signature
[System.Obsolete("Deprecated. Use the Action<> overload", false)]
public ulong SetShadowPriority(
    uint shadowPriority,
    Sansar.Script.ScriptBase.OperationComplete handler
)
```

Sets the shadow priority of this LightComponent of type LightType.SpotLight.

| Parameter | Type | Description |
|---|---|---|
| `shadowPriority` | [uint](https://learn.microsoft.com/dotnet/api/system.uint32) | Shadow priority. |
| `handler` | [Sansar.Script.ScriptBase.OperationComplete](/scripting/api/sansar.script/scriptbase.operationcomplete) | Handler to be called when the event completes. |

**Returns:** [ulong](https://learn.microsoft.com/dotnet/api/system.uint64) — The return value is an internal event id.

<details class="api-remarks"><summary>Remarks</summary>

Set this to zero to turn off shadows. This method only affects spot lights. The renderer prioritizes shadows cast from higher priority lights first. This asynchronous method queues the write then returns. To block until the write has occurred, pass this method to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor) while in a coroutine.

</details>

</div>

<div class="api-card" id="setshadowpriority-uint32-action">
<span id="M:Sansar.Simulation.LightComponent.SetShadowPriority(System.UInt32,System.Action{Sansar.Script.OperationCompleteEvent})"></span>

```csharp signature
public void SetShadowPriority(
    uint shadowPriority,
    Action<Sansar.Script.OperationCompleteEvent> handler
)
```

Sets the shadow priority of this LightComponent of type LightType.SpotLight.

| Parameter | Type | Description |
|---|---|---|
| `shadowPriority` | [uint](https://learn.microsoft.com/dotnet/api/system.uint32) | Shadow priority. |
| `handler` | [Action&lt;Sansar.Script.OperationCompleteEvent&gt;](https://learn.microsoft.com/dotnet/api/system.action-1) | Handler to be called when the event completes. |

<details class="api-remarks"><summary>Remarks</summary>

Set this to zero to turn off shadows. This method only affects spot lights. The renderer prioritizes shadows cast from higher priority lights first. This asynchronous method queues the write then returns. To block until the write has occurred, pass this method to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor) while in a coroutine.

</details>

</div>

### ToString

<div class="api-card">
<span id="M:Sansar.Simulation.LightComponent.ToString"></span>
<span id="M:Sansar.Simulation.LightComponent.ToString()"></span>

```csharp signature
public override string ToString()
```

A string representation of this object.

**Returns:** [string](https://learn.microsoft.com/dotnet/api/system.string) — A string representation of this object.

<details class="api-remarks"><summary>Remarks</summary>

The format of this string may change between releases.

</details>

</div>


## Used in examples

- [ScriptLibrary/Scene/Light.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ScriptLibrary/Scene/Light.cs)
- [ScriptLibrary/Scene/LightOnOff.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ScriptLibrary/Scene/LightOnOff.cs)

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