Skip to content

Game.Prefabs.ProceduralLight

Assembly: Assembly-CSharp (game assembly)
Namespace: Game.Prefabs

Type: struct ProceduralLight

Base: Unity.Entities.IBufferElementData

Summary:
ProceduralLight is a dynamic buffer element type used to store per-light procedural data for prefab entities (lights) in the game. It holds color information (two color slots), an emissive purpose enum, a response/interpolation speed, and an animation index. The struct is marked with [InternalBufferCapacity(0)], meaning the initial internal storage capacity is zero and the buffer will be stored as a separate heap allocation (useful for variable-length lists of lights).


Fields

  • public float4 m_Color
    Stores the primary color for this procedural light (Unity.Mathematics.float4 — typically RGBA or RGB+unused/alpha).

  • public float4 m_Color2
    Secondary color for blending/alternate color state. Also a float4.

  • public EmissiveProperties.Purpose m_Purpose
    Enum value indicating the purpose/category of this emissive element (drives how the light/emissive system treats it). See EmissiveProperties.Purpose for possible values.

  • public float m_ResponseSpeed
    A speed multiplier controlling how quickly the light responds or interpolates between states (e.g., color transitions, intensity changes).

  • public int m_AnimationIndex
    Index selecting which procedural animation/variation to use for this light instance.

Properties

This type does not declare any C# properties. It is a plain IBufferElementData struct with public fields intended for use in a DynamicBuffer.

Constructors

  • No explicit constructors are defined. The type uses the default (parameterless) struct constructor. Initialize fields manually when adding elements to the buffer.

Methods

  • This struct declares no methods. It is a plain data container used by ECS systems and jobs.

Usage Example

using Unity.Entities;
using Unity.Mathematics;
using Game.Prefabs;

// Example: add or get the buffer for an entity and append a ProceduralLight element
EntityManager em = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity entity = /* obtain or create entity for a prefab/light */;

// Ensure a DynamicBuffer<ProceduralLight> exists on the entity
if (!em.HasComponent<ProceduralLight>(entity))
{
    em.AddBuffer<ProceduralLight>(entity);
}

var buffer = em.GetBuffer<ProceduralLight>(entity);

// Add a procedural light element
buffer.Add(new ProceduralLight
{
    m_Color = new float4(1f, 0.8f, 0.6f, 1f),    // warm primary color
    m_Color2 = new float4(0.2f, 0.2f, 1f, 1f),   // secondary tint
    m_Purpose = EmissiveProperties.Purpose.General,
    m_ResponseSpeed = 2.0f,
    m_AnimationIndex = 0
});

Notes and tips: - Because this implements IBufferElementData, access it via DynamicBuffer in systems (IJobEntity, SystemBase, etc.). - The [InternalBufferCapacity(0)] attribute implies no inline storage; plan for allocations when many elements are present. - Be mindful of blittability and layout when using this struct in jobs; keep fields plain value types for best performance.