The LightComponent handles interactions with lights.
public class LightComponent : Sansar.Script.InstanceInterfaceMembers at a glance
| Kind | Members |
|---|---|
| Fields | ComponentType |
| Properties | ComponentId · IsScriptable · LightType · Name |
| Methods | GetAngle · GetAngularFalloff · GetCastsShadows · GetNearClip · GetNormalizedColor · GetRange · GetRelativeIntensity · GetShadowPriority · SetAngle · SetAngularFalloff · SetCastsShadows · SetColorAndIntensity · SetNearClip · SetRange · SetShadowPriority · ToString |
Fields
ComponentType
public static readonly ComponentType ComponentTypeThe LightComponent.ComponentType of this component
Properties
ComponentId
public Sansar.Script.ComponentId ComponentId { get; }Retrieves the component id for this LightComponent.
Value: Sansar.Script.ComponentId — The id.
IsScriptable
public bool IsScriptable { get; }The scriptable flag for this LightComponent.
Value: bool — Whether or not this light can have properties changed by script.
LightType
public LightType LightType { get; }The light type for this LightComponent.
Value: LightType — Light type enum for the light component.
Name
public string Name { get; }This LightComponent name, as specified in the editor.
Methods
GetAngle
public float GetAngle()Retrieves the cone angle of this LightComponent.
Returns: float — The angle in degrees.
GetAngularFalloff
public float GetAngularFalloff()Retrieves the angular falloff of this LightComponent.
Returns: float — The angular falloff.
GetCastsShadows
public bool GetCastsShadows()Retrieves whether this LightComponent casts shadows.
Returns: bool — The shadow cast state.
GetNearClip
public float GetNearClip()Retrieves the near clip distance of this LightComponent.
Returns: float — The near clip distance.
GetNormalizedColor
public Sansar.Color GetNormalizedColor()Retrieves the normalized color of this LightComponent.
Returns: Sansar.Color — The normalized color.
Remarks
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.
GetRange
public float GetRange()Retrieves the current range of this LightComponent.
Returns: float — The range.
GetRelativeIntensity
public float GetRelativeIntensity()Retrieves the intensity of this LightComponent based on its normalized color.
Returns: float — The intensity based on a normalized color.
Remarks
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.
GetShadowPriority
public uint GetShadowPriority()Retrieves the shadow priority of this LightComponent.
Returns: uint — The shadow priority.
SetAngle
public void SetAngle(float angle)Sets the cone angle for this LightComponent of type LightType.SpotLight.
| Parameter | Type | Description |
|---|---|---|
angle | float | The angle in degrees, 1 to 160. |
Remarks
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 while in a coroutine.
[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 | The angle in degrees, 1 to 160. |
handler | Sansar.Script.ScriptBase.OperationComplete | Handler to be called when the event completes. |
Returns: ulong — The return value is an internal event id.
Remarks
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 while in a coroutine.
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 | The angle in degrees, 1 to 160. |
handler | Action<Sansar.Script.OperationCompleteEvent> | Handler to be called when the event completes. |
Remarks
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 while in a coroutine.
SetAngularFalloff
public void SetAngularFalloff(float angularFalloff)Sets the angular falloff for this LightComponent of type LightType.SpotLight.
| Parameter | Type | Description |
|---|---|---|
angularFalloff | float | The angular falloff, 0.01 to 1. |
Remarks
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 while in a coroutine.
[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 | The angular falloff, 0.01 to 1. |
handler | Sansar.Script.ScriptBase.OperationComplete | Handler to be called when the event completes. |
Returns: ulong — The return value is an internal event id.
Remarks
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 while in a coroutine.
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 | The angular falloff, 0.01 to 1. |
handler | Action<Sansar.Script.OperationCompleteEvent> | Handler to be called when the event completes. |
Remarks
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 while in a coroutine.
SetCastsShadows
public void SetCastsShadows(bool castsShadows)Sets whether shadows are cast from this LightComponent of type LightType.SpotLight.
| Parameter | Type | Description |
|---|---|---|
castsShadows | bool | True to cast shadows. |
Remarks
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 while in a coroutine.
[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 | True to cast shadows. |
handler | Sansar.Script.ScriptBase.OperationComplete | Handler to be called when the event completes. |
Returns: ulong — The return value is an internal event id.
Remarks
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 while in a coroutine.
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 | True to cast shadows. |
handler | Action<Sansar.Script.OperationCompleteEvent> | Handler to be called when the event completes. |
Remarks
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 while in a coroutine.
SetColorAndIntensity
public void SetColorAndIntensity(Sansar.Color color, float intensity)Sets the color for this LightComponent.
| Parameter | Type | Description |
|---|---|---|
color | Sansar.Color | The color. |
intensity | float | The intensity, 0 to 100. |
Remarks
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 while in a coroutine.
[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 | The color. |
intensity | float | The intensity, 0 to 100. |
handler | Sansar.Script.ScriptBase.OperationComplete | Handler to be called when the event completes. |
Returns: ulong — The return value is an internal event id.
Remarks
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 while in a coroutine.
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 | The color. |
intensity | float | The intensity, 0 to 100. |
handler | Action<Sansar.Script.OperationCompleteEvent> | Handler to be called when the event completes. |
Remarks
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 while in a coroutine.
SetNearClip
public void SetNearClip(float nearClip)Sets the near clip plane distance for this LightComponent of type LightType.SpotLight.
| Parameter | Type | Description |
|---|---|---|
nearClip | float | The near clip distance, 0 to 500. |
Remarks
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 while in a coroutine.
[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 | The near clip distance, 0 to 500. |
handler | Sansar.Script.ScriptBase.OperationComplete | Handler to be called when the event completes. |
Returns: ulong — The return value is an internal event id.
Remarks
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 while in a coroutine.
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 | The near clip distance, 0 to 500. |
handler | Action<Sansar.Script.OperationCompleteEvent> | Handler to be called when the event completes. |
Remarks
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 while in a coroutine.
SetRange
public void SetRange(float range)Sets the range for this LightComponent.
| Parameter | Type | Description |
|---|---|---|
range | float | The range, 1 to 500. |
Remarks
This asynchronous method queues the write then returns. To block until the write has occurred, pass this method to ScriptBase.WaitFor while in a coroutine.
[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 | The range, 1 to 500. |
handler | Sansar.Script.ScriptBase.OperationComplete | Handler to be called when the event completes. |
Returns: ulong — The return value is an internal event id.
Remarks
This asynchronous method queues the write then returns. To block until the write has occurred, pass this method to ScriptBase.WaitFor while in a coroutine.
public void SetRange(
float range,
Action<Sansar.Script.OperationCompleteEvent> handler
)Sets the range for this LightComponent.
| Parameter | Type | Description |
|---|---|---|
range | float | The range, 1 to 500. |
handler | Action<Sansar.Script.OperationCompleteEvent> | Handler to be called when the event completes. |
Remarks
This asynchronous method queues the write then returns. To block until the write has occurred, pass this method to ScriptBase.WaitFor while in a coroutine.
SetShadowPriority
public void SetShadowPriority(uint shadowPriority)Sets the shadow priority of this LightComponent of type LightType.SpotLight.
| Parameter | Type | Description |
|---|---|---|
shadowPriority | uint | Shadow priority. |
Remarks
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 while in a coroutine.
[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 | Shadow priority. |
handler | Sansar.Script.ScriptBase.OperationComplete | Handler to be called when the event completes. |
Returns: ulong — The return value is an internal event id.
Remarks
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 while in a coroutine.
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 | Shadow priority. |
handler | Action<Sansar.Script.OperationCompleteEvent> | Handler to be called when the event completes. |
Remarks
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 while in a coroutine.
ToString
public override string ToString()A string representation of this object.
Returns: string — A string representation of this object.
Remarks
The format of this string may change between releases.
Used in examples
Generated from the Sansar 47.10.0 client ScriptApi snapshot.