Class VehicleLight
Represents a single vehicle light that can contain multiple LightSource implementations.
Namespace: NWH.VehiclePhysics2.Effects
Assembly: NWH.VehiclePhysics2.dll
Syntax
[Serializable]
public class VehicleLight
Remarks
VehicleLight is a container for one or more LightSource objects. This allows a single light (e.g., headlight) to be represented by multiple components - for example, a Spot Light for the beam plus an emissive mesh for the lens glow. All sources within a VehicleLight turn on/off together.
Fields
isOn
Declaration
protected bool isOn
Field Value
| Type | Description |
|---|---|
| bool |
lightSources
Collection of LightSource components that together represent this vehicle light. Multiple sources allow combining different light implementations. For example, a headlight can use both a Spot Light (for scene illumination) and an emissive mesh (for the lens appearance). All sources in this list are controlled together as a single unit.
Declaration
[Tooltip(" All the light sources representing the vehicle light.\r\n E.g. low beam can be represented by a directional light to represent light beam and\r\n and emissive mesh to represent light optics.")]
public List<LightSource> lightSources
Field Value
| Type | Description |
|---|---|
| List<LightSource> |
Properties
On
Gets or sets whether this light is currently on. When set directly, bypasses the normal TurnOn/TurnOff logic. Use SetState(), TurnOn(), or TurnOff() for proper control with source management.
Declaration
public bool On { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
SetState(bool)
Sets the light state by calling TurnOn() or TurnOff() based on the state parameter.
Declaration
public void SetState(bool state)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | state | True to turn on, false to turn off. |
Toggle()
Toggles the light state. If currently on, turns it off. If currently off, turns it on.
Declaration
public void Toggle()
TurnOff()
Turns off all light sources in this vehicle light. Calls TurnOff() on each LightSource in the lightSources list.
Declaration
public void TurnOff()
TurnOn()
Turns on all light sources in this vehicle light. Calls TurnOn() on each LightSource in the lightSources list.
Declaration
public void TurnOn()