Skip to content

Game.Prefabs.AnimationClip

Assembly: Game (Cities: Skylines 2 game assembly)
Namespace: Game.Prefabs

Type: struct

Base: Unity.Entities.IBufferElementData

Summary:
Represents a single animation clip entry stored in an ECS dynamic buffer for prefabs. Contains texture/UV mapping info for sprite-sheet driven animations, playback and timing parameters, root-motion offsets/rotation, speed and motion ranges, and identifying indices for prop / info lookup. This struct is intended to be stored in a DynamicBuffer on an entity that owns animation data for a prefab.


Fields

  • public float m_TextureOffset
    Offset (in texture units) where this clip starts in the animation texture / atlas (usually U coordinate start).

  • public float m_TextureRange
    Range (width) in texture units used by this clip (usually how many U units the clip spans).

  • public float m_OnePixelOffset
    One-pixel offset value used for correct texel sampling / pixel-perfect UV adjustments.

  • public float m_TextureWidth
    Width of the texture (in pixels or normalized units depending on usage) used to convert offsets to UVs.

  • public float m_OneOverTextureWidth
    Precomputed 1.0 / m_TextureWidth for faster UV math.

  • public float m_OneOverPixelOffset
    Precomputed 1.0 / m_OnePixelOffset for faster calculations when converting pixel offsets.

  • public float m_AnimationLength
    Duration/length of the animation clip in seconds.

  • public float m_MovementSpeed
    Speed multiplier used for root motion or movement driven by this clip.

  • public float m_TargetValue
    Generic numeric target value — used by gameplay or blending logic (meaning depends on how the animation system consumes it).

  • public float m_FrameRate
    Frames per second (fps) used by this clip (useful for frame-based sampling).

  • public int m_RootMotionBone
    Index of the bone used for root motion extraction (or -1 if none).

  • public int m_InfoIndex
    Index into some info table (e.g., shared animation info array) used by the engine.

  • public int m_PropClipIndex
    Index of the prop-specific clip (used when animation is for an attached prop).

  • public int2 m_MotionRange
    Integer range describing discrete motion frame indices or other motion index min/max (Colossal.Mathematics.int2).

  • public float3 m_RootOffset
    Root motion position offset applied by this clip (Colossal.Mathematics/Unity.Mathematics float3).

  • public quaternion m_RootRotation
    Root motion rotation applied by this clip (Unity.Mathematics.quaternion).

  • public Bounds1 m_SpeedRange
    Speed range (min/max) wherein this clip is valid or blended; custom Bounds1 type used by the game to describe 1D ranges.

  • public AnimatedPropID m_PropID
    Identifier for an animated prop associated with this clip (custom game type).

  • public AnimationType m_Type
    Classification of the animation (idle, walk, run, prop animation, etc. — game-specific enum).

  • public AnimationLayer m_Layer
    Layer index/type for animation blending (game-specific enum).

  • public ActivityType m_Activity
    High-level activity category (game-specific enum, e.g., working, resting).

  • public ActivityCondition m_Conditions
    Conditions flag/enum indicating when this animation should play (game-specific).

  • public AnimationPlayback m_Playback
    Playback mode (loop, once, ping-pong, etc. — game-specific enum).

Properties

  • This struct defines no C# properties. It's a plain data buffer element with public fields for fast ECS access.

Constructors

  • public AnimationClip()
    No explicit constructors are defined. The struct has the default value-type constructor, and instances are typically created and populated inline or via initializer when adding to a DynamicBuffer.

Note: The type is decorated with [InternalBufferCapacity(0)], which indicates the dynamic buffer has an internal capacity of 0 and will allocate storage on the heap when elements are added.

Methods

  • This struct does not define any methods.

Usage Example

// Example: Adding animation clips to an entity buffer in a system or setup code
EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity entity = entityManager.CreateEntity();

// Add the buffer (DynamicBuffer<AnimationClip>) to the entity
var buffer = entityManager.AddBuffer<Game.Prefabs.AnimationClip>(entity);

// Add a clip
buffer.Add(new Game.Prefabs.AnimationClip
{
    m_TextureOffset = 0f,
    m_TextureRange = 128f,
    m_OnePixelOffset = 0.5f,
    m_TextureWidth = 512f,
    m_OneOverTextureWidth = 1f / 512f,
    m_AnimationLength = 1.0f,
    m_MovementSpeed = 1.2f,
    m_TargetValue = 0f,
    m_FrameRate = 24f,
    m_RootMotionBone = -1,
    m_InfoIndex = 0,
    m_PropClipIndex = -1,
    m_MotionRange = new Colossal.Mathematics.int2(0, 0),
    m_RootOffset = new Unity.Mathematics.float3(0f, 0f, 0f),
    m_RootRotation = Unity.Mathematics.quaternion.identity,
    m_SpeedRange = new Bounds1 { min = 0f, max = 2f }, // example; actual constructor depends on Bounds1
    m_PropID = default,       // set appropriate AnimatedPropID
    m_Type = default,         // set appropriate AnimationType
    m_Layer = default,        // set appropriate AnimationLayer
    m_Activity = default,     // set appropriate ActivityType
    m_Conditions = default,   // set appropriate ActivityCondition
    m_Playback = default      // set appropriate AnimationPlayback
});

Notes / Tips - This struct is optimized for use in ECS (IBufferElementData) — prefer bulk operations and avoid per-field reflection or managed helpers on the hot path. - Many field types are game-specific enums/structs (AnimatedPropID, AnimationType, AnimationLayer, ActivityType, ActivityCondition, AnimationPlayback, Bounds1). Check the game's assemblies for their definitions to understand valid values and ranges. - [InternalBufferCapacity(0)] means the buffer has no inline storage; adding elements will allocate, so consider reusing buffers where appropriate to reduce allocations.