Skip to content

Game.Rendering.AnimatedInstance

Assembly: Assembly-CSharp
Namespace: Game.Rendering

Type: struct

Base: System.ValueType

Summary:
Represents a lightweight animation instance used by the rendering system. This plain-old-data struct holds indices and a frame progress value for a single animated element (for example, a sprite or mesh animation). It's designed to be blittable and cheap to copy so it can be stored in arrays or used in jobs/NativeArrays for high-performance rendering code.


Fields

  • public int m_MetaIndex
    Index referencing animation metadata or a descriptor table (e.g., which animation resource or set to use for this instance).

  • public int m_CurrentIndex
    Current integer frame index (or the current key/frame within the animation sequence).

  • public float m_CurrentFrame
    Fractional/current frame progress used for interpolation between frames (range typically 0..1 or used as sub-frame progress depending on the animation system).

Properties

  • (none)
    This struct exposes only public fields; there are no properties defined.

Constructors

  • (default struct constructor)
    No explicit constructors are defined. Use the default constructor or object initializer to create instances:
var inst = new AnimatedInstance { m_MetaIndex = 0, m_CurrentIndex = 0, m_CurrentFrame = 0f };

Methods

  • (none)
    There are no methods defined on this struct. Any update logic or frame advancement is handled by the animation/rendering systems that own these instances.

Usage Example

// Create and initialize a single instance
AnimatedInstance inst = new AnimatedInstance {
    m_MetaIndex = 2,
    m_CurrentIndex = 0,
    m_CurrentFrame = 0f
};

// Advance frame (example logic performed by animation system)
inst.m_CurrentFrame += deltaTime * framesPerSecond;
if (inst.m_CurrentFrame >= 1f) {
    inst.m_CurrentFrame -= 1f;
    inst.m_CurrentIndex++;
    // wrap or clamp inst.m_CurrentIndex according to animation length
}

// Storing in an array or NativeArray for jobified rendering
AnimatedInstance[] instances = new AnimatedInstance[count];
// or for Burst/Jobs:
using (var native = new Unity.Collections.NativeArray<AnimatedInstance>(count, Unity.Collections.Allocator.TempJob)) {
    native[0] = inst;
    // pass native to a job for parallel processing/rendering
}

{{ Notes: - The struct is intentionally minimal and intended to be used by the engine's animation/rendering pipeline. - Because it contains only primitive types, it is blittable and well-suited for low-level memory containers (arrays, NativeArray) and multithreaded jobs. - Interpretation of the fields (e.g., whether m_CurrentFrame is 0..1 or actual frame time) depends on the surrounding animation system; check consuming code for exact semantics. }}