Game.Prefabs.AnimationMotion
Assembly: Assembly-CSharp.dll
Namespace: Game.Prefabs
Type: struct
Base: System.ValueType, Unity.Entities.IBufferElementData
Summary:
AnimationMotion is a plain IBufferElementData container used by the game's ECS to represent a single motion key (start/end position offsets and start/end rotations) for prefab animations. Each element stores start/end translation offsets (float3) and start/end orientations (quaternion). The type is marked with [InternalBufferCapacity(0)], so the DynamicBuffer holding these elements has no inline capacity and will allocate storage externally when used.
Fields
-
public float3 m_StartOffset
Stores the starting translation offset for this motion key relative to the animated object. -
public float3 m_EndOffset
Stores the ending translation offset for this motion key. -
public quaternion m_StartRotation
Stores the starting rotation for this motion key. -
public quaternion m_EndRotation
Stores the ending rotation for this motion key.
Properties
- None.
This struct exposes only public fields and implements IBufferElementData; it defines no properties.
Constructors
- Implicit default constructor (
public AnimationMotion()
provided by the runtime)
There is no explicit constructor defined in the source. As a value type it has the default parameterless constructor that leaves fields uninitialized to their default values.
Methods
- None.
This type is a data container only — it defines no instance or static methods. It is intended to be used inside a DynamicBufferon an entity.
Usage Example
// Example usage inside a SystemBase or ComponentSystem
protected override void OnUpdate()
{
Entities.ForEach((Entity entity, ref SomeAnimationTag tag) =>
{
// Add or get the buffer for animation motion keys
var buffer = EntityManager.GetBuffer<AnimationMotion>(entity);
// Clear and populate with two keys
buffer.Clear();
buffer.Add(new AnimationMotion {
m_StartOffset = new float3(0f, 0f, 0f),
m_EndOffset = new float3(0f, 1f, 0f),
m_StartRotation = quaternion.identity,
m_EndRotation = quaternion.AxisAngle(new float3(0,1,0), math.radians(90f))
});
// ... use buffer elements when sampling animation for this entity ...
}).WithoutBurst().Run();
}
Additional notes:
- Types float3 and quaternion come from Unity.Mathematics and are blittable, making this struct suitable for Burst-compiled jobs and efficient ECS usage.
- [InternalBufferCapacity(0)] indicates no inline storage; the buffer will allocate memory externally (useful when element counts vary and/or can be large).
- Use DynamicBuffer