Skip to content

Game.Prefabs.LightAnimation

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: struct

Base: Unity.Entities.IBufferElementData

Summary:
LightAnimation is an ECS buffer element used to describe a light animation for prefab entities. The struct uses explicit layout to pack a duration (in frames) together with a union-like overlay that can represent the animation either as an AnimationCurve1 or as a SignalAnimation. The struct is marked with InternalBufferCapacity(0), so the dynamic buffer stores elements externally (no inline pre-allocated elements). Because m_AnimationCurve and m_SignalAnimation share the same field offset, they are mutually exclusive — only one should be used at a time.


Fields

  • public uint m_DurationFrames
    Duration of the animation in frames. Stored at offset 0. Typically used to determine the length of the animation sequence.

  • public AnimationCurve1 m_AnimationCurve
    Animation curve data stored at offset 4. Represents curve-driven animation state (e.g., intensity/brightness over time). This field overlaps with m_SignalAnimation; use this when the animation is defined procedurally by a curve.

  • public SignalAnimation m_SignalAnimation
    Signal-based animation data stored at offset 4. Represents discrete signal pattern animation. This field overlaps with m_AnimationCurve; use this when the animation is defined by signal pattern data.

Properties

  • None. This is a plain data buffer element with public fields.

Constructors

  • Implicit default constructor (value type)
    Structs in C# have a default parameterless constructor that zero-initializes fields. There are no explicit constructors defined in the source.

Methods

  • None. This type only contains data fields and no methods.

Usage Example

// Example: add a LightAnimation buffer to an entity and push an element.
// Note: AnimationCurve1 and SignalAnimation constructors/details depend on their definitions.
// Only set one of m_AnimationCurve or m_SignalAnimation because they overlap.

var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
var entity = entityManager.CreateEntity();

// add a dynamic buffer of LightAnimation
var buffer = entityManager.AddBuffer<Game.Prefabs.LightAnimation>(entity);

// add an animation that uses an animation curve
var anim = new Game.Prefabs.LightAnimation
{
    m_DurationFrames = 60u,
    m_AnimationCurve = new AnimationCurve1() // initialize appropriately
};
buffer.Add(anim);

// OR, add a signal-based animation (do not set m_AnimationCurve in this case)
var signalAnim = new Game.Prefabs.LightAnimation
{
    m_DurationFrames = 30u,
    m_SignalAnimation = new SignalAnimation() // initialize appropriately
};
buffer.Add(signalAnim);

Notes: - Because the struct uses [StructLayout(LayoutKind.Explicit)] with overlapping fields at offset 4, assign and read only the relevant union field (m_AnimationCurve or m_SignalAnimation) to avoid data corruption. - [InternalBufferCapacity(0)] means the buffer has no inline storage; elements are stored in an external dynamic buffer managed by the Entities package.