Light

class in UnityEngine

/

Inherits from:Behaviour

Switch to Manual

Description

Script interface for light components.

Use this to control all aspects of Unity's lights. The properties are an exact match for the values shown in the Inspector.

Обычно источник света создается в редакторе, но иногда вам может понадобиться создать источник света через код (из скрипта)

using UnityEngine;

public class Example : MonoBehaviour { void Start() { // Make a game object GameObject lightGameObject = new GameObject("The Light");

// Add the light component Light lightComp = lightGameObject.AddComponent<Light>();

// Set color and position lightComp.color = Color.blue;

// Set the position (or any transform property) lightGameObject.transform.position = new Vector3(0, 5, 0); } }

Variables

areaSizeThe size of the area light (Editor only).
bakingOutputThis property describes the output of the last Global Illumination bake.
bounceIntensityThe multiplier that defines the strength of the bounce lighting.
boundingSphereOverrideBounding sphere used to override the regular light bounding sphere during culling.
colorЦвет источника света
colorTemperature The color temperature of the light. Correlated Color Temperature (abbreviated as CCT) is multiplied with the color filter when calculating the final color of a light source. The color temperature of the electromagnetic radiation emitted from an ideal black body is defined as its surface temperature in Kelvin. White is 6500K according to the D65 standard. A candle light is 1800K and a soft warm light bulb is 2700K. If you want to use colorTemperature, GraphicsSettings.lightsUseLinearIntensity and Light.useColorTemperature has to be enabled. See Also: GraphicsSettings.lightsUseLinearIntensity, GraphicsSettings.useColorTemperature.
commandBufferCountNumber of command buffers set up on this light (Read Only).
cookieThe cookie texture projected by the light.
cookieSizeThe size of a directional light's cookie.
cullingMaskThis is used to light certain objects in the Scene selectively.
flareThe flare asset to use for this light.
innerSpotAngleThe angle of the light's spotlight inner cone in degrees.
intensityThe Intensity of a light is multiplied with the Light color.
layerShadowCullDistancesPer-light, per-layer shadow culling distances. Directional lights only.
lightmapBakeTypeThis property describes what part of a light's contribution can be baked (Editor only).
lightShadowCasterModeAllows you to override the global Shadowmask Mode per light. Only use this with render pipelines that can handle per light Shadowmask modes. Incompatible with the legacy renderers.
rangeДиапазон(размер) источника света
renderingLayerMaskDetermines which rendering LayerMask this Light affects.
renderModeHow to render the light.
shadowAngleControls the amount of artificial softening applied to the edges of shadows cast by directional lights.
shadowBiasShadow mapping constant bias.
shadowCustomResolutionThe custom resolution of the shadow map.
shadowMatrixOverrideProjection matrix used to override the regular light matrix during shadow culling.
shadowNearPlaneNear plane value to use for shadow frustums.
shadowNormalBiasShadow mapping normal-based bias.
shadowRadiusControls the amount of artificial softening applied to the edges of shadows cast by the Point or Spot light.
shadowResolutionThe resolution of the shadow map.
shadowsКак этот источник света отбрасывает тени
shadowStrengthИнтенсивность теней
shapeThis property describes the shape of the spot light. Only Scriptable Render Pipelines use this property; the built-in renderer does not support it.
spotAngleThe angle of the light's spotlight cone in degrees.
typeТип света.
useBoundingSphereOverrideSet to true to override light bounding sphere for culling.
useColorTemperatureSet to true to use the color temperature.
useShadowMatrixOverrideSet to true to enable custom matrix for culling during shadows.
useViewFrustumForShadowCasterCullWhether to cull shadows for this Light when the Light is outside of the view frustum.

Public Functions

AddCommandBufferAdd a command buffer to be executed at a specified place.
AddCommandBufferAsyncAdds a command buffer to the GPU's async compute queues and executes that command buffer when graphics processing reaches a given point.
GetCommandBuffersGet command buffers to be executed at a specified place.
RemoveAllCommandBuffersRemove all command buffers set on this light.
RemoveCommandBufferRemove command buffer from execution at a specified place.
RemoveCommandBuffersRemove command buffers from execution at a specified place.
ResetRevert all light parameters to default.
SetLightDirtySets a light dirty to notify the light baking backends to update their internal light representation (Editor only).

Inherited members

Variables

enabledВключенное Поведение обновляется, выключенное Поведение не обновляется.
isActiveAndEnabledHas the Behaviour had active and enabled called?
gameObjectИгровой объект к которому прикреплён данный компонент. Компонент всегда прикреплён к игровому объекту.
tagТег данного игрового объекта.
transformThe Transform attached to this GameObject.
hideFlagsShould the object be hidden, saved with the Scene or modifiable by the user?
nameThe name of the object.

Public Functions

BroadcastMessageВызывает метод названный methodName на каждом MonoBehaviour этого game object-а или любого из его потомков.
CompareTagПомечен ли данный игровой объект тегом tag?
GetComponentReturns the component of Type type if the GameObject has one attached, null if it doesn't. Will also return disabled components.
GetComponentInChildrenВозвращает компонент типа type в GameObject или некоторого его потомка через поиск в глубину.
GetComponentInParentВозвращает все компоненты типа type из GameObject'а или из любого его родителя.
GetComponentsВозвращает все компоненты типа type в GameObject.
GetComponentsInChildrenВозвращает все компоненты типа type в GameObject или любому из его потомков.
GetComponentsInParentВозвращает все компоненты типа type в GameObject или любому из его родителей.
SendMessageВызывает метод с названием methodName в каждом MonoBehaviour в этом игровом объекте.
SendMessageUpwardsВызывает метод с именем methodName в каждом MonoBehaviour в этом игровом объекте и в каждом предке поведения.
TryGetComponentGets the component of the specified type, if it exists.
GetInstanceIDReturns the instance id of the object.
ToStringReturns the name of the object.

Static Functions

DestroyRemoves a GameObject, component or asset.
DestroyImmediateDestroys the object obj immediately. You are strongly recommended to use Destroy instead.
DontDestroyOnLoadDo not destroy the target Object when loading a new Scene.
FindObjectOfTypeReturns the first active loaded object of Type type.
FindObjectsOfTypeGets a list of all loaded objects of Type type.
InstantiateClones the object original and returns the clone.

Operators

boolDoes the object exist?
operator !=Compares if two objects refer to a different object.
operator ==Compares two object references to see if they refer to the same object.
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961