Skip to content

Get Sansar

Script API

LightComponent

Where: Client
More page actions

For the complete documentation index, see llms.txt. This page is also available as Markdown.

The LightComponent handles interactions with lights.

public class LightComponent : Sansar.Script.InstanceInterface

Members at a glance

KindMembers
FieldsComponentType
PropertiesComponentId · IsScriptable · LightType · Name
MethodsGetAngle · GetAngularFalloff · GetCastsShadows · GetNearClip · GetNormalizedColor · GetRange · GetRelativeIntensity · GetShadowPriority · SetAngle · SetAngularFalloff · SetCastsShadows · SetColorAndIntensity · SetNearClip · SetRange · SetShadowPriority · ToString

Fields

ComponentType

public static readonly ComponentType ComponentType

The 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

Added in 33.2.0
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.

ParameterTypeDescription
anglefloatThe 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.

Deprecated
[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.

ParameterTypeDescription
anglefloatThe angle in degrees, 1 to 160.
handlerSansar.Script.ScriptBase.OperationCompleteHandler 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.

ParameterTypeDescription
anglefloatThe angle in degrees, 1 to 160.
handlerAction<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.

ParameterTypeDescription
angularFallofffloatThe 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.

Deprecated
[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.

ParameterTypeDescription
angularFallofffloatThe angular falloff, 0.01 to 1.
handlerSansar.Script.ScriptBase.OperationCompleteHandler 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.

ParameterTypeDescription
angularFallofffloatThe angular falloff, 0.01 to 1.
handlerAction<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.

ParameterTypeDescription
castsShadowsboolTrue 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.

Deprecated
[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.

ParameterTypeDescription
castsShadowsboolTrue to cast shadows.
handlerSansar.Script.ScriptBase.OperationCompleteHandler 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.

ParameterTypeDescription
castsShadowsboolTrue to cast shadows.
handlerAction<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.

ParameterTypeDescription
colorSansar.ColorThe color.
intensityfloatThe 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.

Deprecated
[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.

ParameterTypeDescription
colorSansar.ColorThe color.
intensityfloatThe intensity, 0 to 100.
handlerSansar.Script.ScriptBase.OperationCompleteHandler 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.

ParameterTypeDescription
colorSansar.ColorThe color.
intensityfloatThe intensity, 0 to 100.
handlerAction<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.

ParameterTypeDescription
nearClipfloatThe 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.

Deprecated
[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.

ParameterTypeDescription
nearClipfloatThe near clip distance, 0 to 500.
handlerSansar.Script.ScriptBase.OperationCompleteHandler 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.

ParameterTypeDescription
nearClipfloatThe near clip distance, 0 to 500.
handlerAction<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.

ParameterTypeDescription
rangefloatThe 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.

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

Sets the range for this LightComponent.

ParameterTypeDescription
rangefloatThe range, 1 to 500.
handlerSansar.Script.ScriptBase.OperationCompleteHandler 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.

ParameterTypeDescription
rangefloatThe range, 1 to 500.
handlerAction<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.

ParameterTypeDescription
shadowPriorityuintShadow 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.

Deprecated
[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.

ParameterTypeDescription
shadowPriorityuintShadow priority.
handlerSansar.Script.ScriptBase.OperationCompleteHandler 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.

ParameterTypeDescription
shadowPriorityuintShadow priority.
handlerAction<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.