Light2D
Casts light in a 2D environment.
Casts light in a 2D environment.
Casts light in a 2D environment. A light is defined as a color, an energy value, a mode (see constants), and various other parameters (range and shadows-related).
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Properties15
BlendModeProperty
public Light2D.BlendModeEnum BlendMode { get; set; }The Light2D's blend mode.
EditorOnlyProperty
public bool EditorOnly { get; set; }If true, Light2D will only appear when editing the scene.
EnabledProperty
public bool Enabled { get; set; }If true, Light2D will emit light.
EnergyProperty
public float Energy { get; set; }The Light2D's energy value. The larger the value, the stronger the light.
RangeItemCullMaskProperty
public int RangeItemCullMask { get; set; }The layer mask. Only objects with a matching CanvasItem.LightMask will be affected by the Light2D. See also Light2D.ShadowItemCullMask, which affects which objects can cast shadows.
Note: Light2D.RangeItemCullMask is ignored by DirectionalLight2D, which will always light a 2D node regardless of the 2D node's CanvasItem.LightMask.
RangeLayerMaxProperty
public int RangeLayerMax { get; set; }Maximum layer value of objects that are affected by the Light2D.
RangeLayerMinProperty
public int RangeLayerMin { get; set; }Minimum layer value of objects that are affected by the Light2D.
RangeZMaxProperty
public int RangeZMax { get; set; }Maximum z value of objects that are affected by the Light2D.
RangeZMinProperty
public int RangeZMin { get; set; }Minimum z value of objects that are affected by the Light2D.
ShadowColorProperty
public Color ShadowColor { get; set; }Color of shadows cast by the Light2D.
ShadowEnabledProperty
public bool ShadowEnabled { get; set; }If true, the Light2D will cast shadows.
ShadowFilterProperty
public Light2D.ShadowFilterEnum ShadowFilter { get; set; }Shadow filter type.
ShadowFilterSmoothProperty
public float ShadowFilterSmooth { get; set; }Smoothing value for shadows. Higher values will result in softer shadows, at the cost of visible streaks that can appear in shadow rendering. Light2D.ShadowFilterSmooth only has an effect if Light2D.ShadowFilter is Light2D.ShadowFilterEnum.Pcf5 or Light2D.ShadowFilterEnum.Pcf13.
ShadowItemCullMaskProperty
public int ShadowItemCullMask { get; set; }Shadow bitmask. For PointLight2D, occluder selection intersects it with LightOccluder2D.OccluderLightMask; applying shadows to receivers also checks CanvasItem.LightMask. This is separate from RangeItemCullMask, which selects illuminated items. Start with all these masks set to 1, then separate groups deliberately.
Methods32
GetBlendModeLight2D.BlendModeEnum
public Light2D.BlendModeEnum GetBlendMode();Light2D.BlendModeEnumGetColorColor
public Color GetColor();ColorGetEnergyfloat
public float GetEnergy();floatGetHeightfloat
public float GetHeight();Returns the light's height, which is used in 2D normal mapping. See PointLight2D.Height and DirectionalLight2D.Height.
floatGetItemCullMaskint
public int GetItemCullMask();intGetItemShadowCullMaskint
public int GetItemShadowCullMask();intGetLayerRangeMaxint
public int GetLayerRangeMax();intGetLayerRangeMinint
public int GetLayerRangeMin();intGetShadowColorColor
public Color GetShadowColor();ColorGetShadowFilterLight2D.ShadowFilterEnum
public Light2D.ShadowFilterEnum GetShadowFilter();Light2D.ShadowFilterEnumGetShadowSmoothfloat
public float GetShadowSmooth();floatGetZRangeMaxint
public int GetZRangeMax();intGetZRangeMinint
public int GetZRangeMin();intIsEditorOnlybool
public bool IsEditorOnly();boolIsEnabledbool
public bool IsEnabled();boolIsShadowEnabledbool
public bool IsShadowEnabled();boolSetBlendModevoid
public void SetBlendMode(Light2D.BlendModeEnum mode);| Name | Type | Default |
|---|---|---|
mode | Light2D.BlendModeEnum | — |
SetColorvoid
public void SetColor(Color color);| Name | Type | Default |
|---|---|---|
color | Color | — |
SetEditorOnlyvoid
public void SetEditorOnly(bool editorOnly);| Name | Type | Default |
|---|---|---|
editorOnly | bool | — |
SetEnabledvoid
public void SetEnabled(bool enabled);| Name | Type | Default |
|---|---|---|
enabled | bool | — |
SetEnergyvoid
public void SetEnergy(float energy);| Name | Type | Default |
|---|---|---|
energy | float | — |
SetHeightvoid
public void SetHeight(float height);Sets the light's height, which is used in 2D normal mapping. See PointLight2D.Height and DirectionalLight2D.Height.
| Name | Type | Default |
|---|---|---|
height | float | — |
SetItemCullMaskvoid
public void SetItemCullMask(int itemCullMask);| Name | Type | Default |
|---|---|---|
itemCullMask | int | — |
SetItemShadowCullMaskvoid
public void SetItemShadowCullMask(int itemShadowCullMask);| Name | Type | Default |
|---|---|---|
itemShadowCullMask | int | — |
SetLayerRangeMaxvoid
public void SetLayerRangeMax(int layer);| Name | Type | Default |
|---|---|---|
layer | int | — |
SetLayerRangeMinvoid
public void SetLayerRangeMin(int layer);| Name | Type | Default |
|---|---|---|
layer | int | — |
SetShadowColorvoid
public void SetShadowColor(Color shadowColor);| Name | Type | Default |
|---|---|---|
shadowColor | Color | — |
SetShadowEnabledvoid
public void SetShadowEnabled(bool enabled);| Name | Type | Default |
|---|---|---|
enabled | bool | — |
SetShadowFiltervoid
public void SetShadowFilter(Light2D.ShadowFilterEnum filter);| Name | Type | Default |
|---|---|---|
filter | Light2D.ShadowFilterEnum | — |
SetShadowSmoothvoid
public void SetShadowSmooth(float smooth);| Name | Type | Default |
|---|---|---|
smooth | float | — |
SetZRangeMaxvoid
public void SetZRangeMax(int z);| Name | Type | Default |
|---|---|---|
z | int | — |
SetZRangeMinvoid
public void SetZRangeMin(int z);| Name | Type | Default |
|---|---|---|
z | int | — |
Light2D.BlendModeEnum
| Value | Description |
|---|---|
Add = 0 | Adds the value of pixels corresponding to the Light2D to the values of pixels under it. This is the common behavior of a light. |
Mix = 2 | Mix the value of pixels corresponding to the Light2D to the values of pixels under it by linear interpolation. |
Sub = 1 | Subtracts the value of pixels corresponding to the Light2D to the values of pixels under it, resulting in inversed light effect. |
Light2D.ShadowFilterEnum
| Value | Description |
|---|---|
None = 0 | No filter applies to the shadow map. This provides hard shadow edges and is the fastest to render. See |
Pcf13 = 2 | Percentage closer filtering (13 samples) applies to the shadow map. This is the slowest shadow filtering mode, and should be used sparingly. See |
Pcf5 = 1 | Percentage closer filtering (5 samples) applies to the shadow map. This is slower compared to hard shadow rendering. See |