Game.Prefabs.EffectAnimation
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: struct
Base: Unity.Entities.IBufferElementData
Summary:
EffectAnimation is a DOTS buffer element type used to store per-effect animation keyframes/segments for a prefab effect. Each element specifies a duration (in frames) and an AnimationCurve1 that defines the interpolation for that segment. The type is marked with [InternalBufferCapacity(0)], so no elements are stored inside the entity chunk — the buffer grows out-of-chunk. Ensure AnimationCurve1 is suitable (blittable) for use inside DOTS containers if you intend to use this from jobs.
Fields
-
public uint m_DurationFrames
Specifies how long this animation element lasts, measured in frames (unsigned). Use integer frame counts; convert to seconds if needed by dividing by your simulation/frame rate. -
public AnimationCurve1 m_AnimationCurve
Holds the curve data used to evaluate animation values across the element's duration. AnimationCurve1 is a game-specific curve type — confirm its layout and that it is safe to store inside DOTS buffers (blittable / deterministic behavior) before using from jobs.
Properties
This type defines no properties.
Constructors
public EffectAnimation()
Implicit default constructor provided by C#. Fields are zero-initialized by default. To create populated instances, use object initialization or a helper factory.
Methods
This type defines no methods.
Usage Example
// Create an entity and add a DynamicBuffer<EffectAnimation>, then add elements.
var em = World.DefaultGameObjectInjectionWorld.EntityManager;
var entity = em.CreateEntity();
// Add the buffer to the entity
var buffer = em.AddBuffer<EffectAnimation>(entity);
// Add an element (using default AnimationCurve1 - replace with a real curve instance)
buffer.Add(new EffectAnimation {
m_DurationFrames = 60u,
m_AnimationCurve = default // replace with a real AnimationCurve1 value
});
// Iterate the buffer (example - evaluate each element)
// Note: replace EvaluateCurve(...) with your implementation for AnimationCurve1.
for (int i = 0; i < buffer.Length; i++)
{
var item = buffer[i];
uint duration = item.m_DurationFrames;
// float value = AnimationCurve1Utilities.Evaluate(item.m_AnimationCurve, normalizedTime);
}
Additional notes: - Because of [InternalBufferCapacity(0)], buffer elements are stored out-of-chunk. If you expect small fixed counts and want better cache layout, consider increasing the capacity value. - m_DurationFrames is frame-based; when mixing with time in seconds, convert appropriately (e.g., seconds = frames / frameRate). - When using this buffer from jobs, ensure AnimationCurve1 is job-compatible (blittable) and avoid UnityEngine.Object references.