Game.Prefabs.EmissiveProperties
Assembly: Assembly-CSharp.dll
Namespace: Game.Prefabs
Type: class
Base: ComponentBase
Summary:
EmissiveProperties describes emissive / procedural lighting configuration for prefabs (vehicles, buildings, props) used by the rendering and lighting systems. It defines individual single-material lights and multi-layer light mappings, per-light properties (color, intensity, animation), animation curves, and grouped signal animations. Typical uses: headlights, brake lights, turn signals, traffic and pedestrian lights, neon/decoration lights and other emissive elements on prefabs. The class exposes helpers to query counts and offsets used by the runtime to index procedural light instances.
Fields
-
public const float kIntensityMultiplier = 100f
A constant multiplier applied to the intensity value to convert designer values into the engine's expected intensity units. -
public List<SingleLightMapping> m_SingleLights
List of lights mapped per material (SingleLightMapping). Each entry maps a material ID to a LightProperties definition so a mesh material can be treated as an independent emissive light. -
public List<MultiLightMapping> m_MultiLights
List of multi-layer lights (MultiLightMapping). These map a prefab layer (layerId) to light properties and are used when a single mesh layer contains multiple emissive areas. -
public List<AnimationProperties> m_AnimationCurves
Optional list of animation curves that can be referenced by LightProperties.animationIndex. Each entry contains duration and an AnimationCurve for time-based brightness modulation. -
public List<SignalGroupAnimation> m_SignalGroupAnimations
Optional list of signal-group animations. Each entry defines a duration and a set of SignalGroupMask values (type defined elsewhere) to animate grouped signals (e.g., multi-bulb turn-signal patterns).
Properties
-
public bool hasSingleLights { get; }
True when m_SingleLights is non-null and contains at least one mapping. -
public bool hasMultiLights { get; }
True when m_MultiLights is non-null and contains at least one mapping. -
public bool hasAnyLights { get; }
True when either single or multi lights are present. -
public int lightsCount { get; }
Total number of defined lights (sum of single and multi lists). This count is used by the prefab/lights initialization to reserve indices.
Nested types (summary)
-
public enum Purpose
Enumerates semantic roles for lights (None, DaytimeRunningLight, Headlight_HighBeam, TurnSignalLeft, RearLight, BrakeLight, TrafficLight_Red, PedestrianLight_Walk, NeonSign, Emergency1..10, MarkerLights, etc.). Purpose helps higher-level systems determine behavior and grouping for animations, blink patterns, and sound/AI interactions. -
public class LightProperties
Base class for light configuration: - Purpose purpose: logical purpose/role of the light.
- Color color: color when on (default white).
- Color colorOff: color when off (default black).
- float intensity: designer intensity value (multiplied by kIntensityMultiplier at runtime).
- float luminance: additional luminance parameter (engine-specific usage).
- float responseTime: how quickly the light responds (fade/transition).
-
int animationIndex: index into m_AnimationCurves (-1 = no curve).
-
public class SingleLightMapping : LightProperties
Extends LightProperties with: -
int materialId: material ID on the prefab mesh to map to this single light.
-
public class MultiLightMapping : LightProperties
Extends LightProperties with: -
int layerId: layer ID (mesh layer) that this multi-light maps to. Default -1 indicates unset.
-
public class AnimationProperties
Contains: - float m_Duration: duration of the animation segment.
-
AnimationCurve m_Curve: curve used to modulate intensity over time.
-
public class SignalGroupAnimation
Contains: - float m_Duration: animation length for the signal group.
- SignalGroupMask[] m_SignalGroupMasks: masks controlling which signal groups are active over time.
Constructors
public EmissiveProperties()
Default parameterless constructor. Typical Unity usage relies on the serialized fields being populated in the inspector; no runtime initialization logic is present in this class constructor.
Methods
-
public int GetSingleLightOffset(int materialId)
Returns the index/offset used by the runtime for a single-material light identified by materialId. The returned offset is > 0 when found; 0 indicates that the material ID was not found. The method accounts for multi-light entries occupying earlier indices (it adds the multi-light count + 1 base offset before searching single lights). This offset is used to map material or layer to the procedural light array index. -
public bool IsSingleLightMaterialId(int materialId)
Returns true if the supplied materialId is present in m_SingleLights. Useful for quickly checking whether a material on a mesh has an associated emissive light mapping. -
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Empty override. This class does not add any special archetype-level components. (Left intentionally blank.) -
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds runtime ECS component requirements for prefabs that have emissive lights: - Always adds ProceduralLight (ReadWrite) so that prefab instances can be assigned procedural light data.
- If animation curves (m_AnimationCurves) or signal-group animations (m_SignalGroupAnimations) are present (non-empty lists), it also adds LightAnimation (ReadWrite) so animations can be processed.
Usage Example
// Example: Inspect an EmissiveProperties instance on a prefab and register required data.
EmissiveProperties emissive = /* get from prefab inspector or component reference */;
if (emissive.hasAnyLights)
{
Debug.Log($"Prefab defines {emissive.lightsCount} emissive lights.");
// Check if a specific material should be treated as an emissive light:
int someMaterialId = 3;
if (emissive.IsSingleLightMaterialId(someMaterialId))
{
int lightOffset = emissive.GetSingleLightOffset(someMaterialId);
Debug.Log($"Material {someMaterialId} maps to light offset {lightOffset}.");
// Use lightOffset to configure ProceduralLight data for the instance
}
// If animations are defined, ensure LightAnimation component is provided by prefab setup
if (emissive.m_AnimationCurves != null && emissive.m_AnimationCurves.Count > 0)
{
// schedule/initialize animation data for this prefab instance...
}
}
Notes: - Intensities set in LightProperties.intensity are typically scaled by kIntensityMultiplier at runtime. Designers should be aware of that factor when authoring values. - SignalGroupMask and other runtime types referenced here are defined elsewhere in the game's codebase; SignalGroupAnimation entries are used to sequence multi-bulb patterns (e.g., turning signals). - SingleLightMapping.materialId refers to a material index on the prefab's mesh; MultiLightMapping.layerId refers to a mesh layer index. Use the appropriate mapping depending on how the model is authored.