Skip to content

Game.Prefabs.AnimationPlayback

Assembly:
Namespace: Game.Prefabs

Type: enum

Base: System.Enum

Summary:
Defines the playback mode for an animation on a prefab. Used by animation systems to determine whether an animation should play once, loop continuously, loop with variations, or be optionally played only once depending on conditions (for example random chance or state). Each enum value represents a distinct behavior the animation player should implement.


Fields

  • Once
    Plays the animation a single time from start to finish and then stops.

  • RandomLoop
    Continuously loops the animation but starts at a random time/offset each loop (or chooses random variations). Useful for avoiding synchronized movement when multiple instances use the same animation.

  • FullLoop
    Plays the animation in a continuous loop from start to end and repeats immediately — a normal continuous loop.

  • HalfLoop
    Plays only part of the animation in a loop (for example the first or middle segment), or loops between two points rather than the full clip. Implementation-specific segment selection is required.

  • OptionalOnce
    An animation that may be played once depending on runtime conditions (for example randomized chance, a game state, or a trigger). If the condition is false, it is skipped.

Properties

  • This enum does not declare instance properties. It is a simple value type used to select behaviour in animation code.

Constructors

  • public AnimationPlayback()
    Enums do not generally define custom constructors; instances are created by assigning one of the named values. The runtime provides the default value construction behaviour for enums.

Methods

  • No methods are declared directly on this enum. Standard System.Enum methods (ToString, HasFlag, GetValues, etc.) are available via the base type.

Usage Example

// Select a playback mode (could be serialized in a prefab component)
AnimationPlayback playback = AnimationPlayback.RandomLoop;

// Example usage in an animation handler:
switch (playback)
{
    case AnimationPlayback.Once:
        PlayAnimationOnce(clip);
        break;
    case AnimationPlayback.OptionalOnce:
        if (Random.value < 0.5f) // example condition
            PlayAnimationOnce(clip);
        break;
    case AnimationPlayback.RandomLoop:
        StartLoopAtRandomOffset(clip);
        break;
    case AnimationPlayback.FullLoop:
        StartFullLoop(clip);
        break;
    case AnimationPlayback.HalfLoop:
        StartHalfLoopSegment(clip, segmentStart, segmentEnd);
        break;
}

Notes: - The exact runtime behavior (how "HalfLoop" segments are defined or how "RandomLoop" chooses offsets/variations) is up to the animation system consuming this enum. Modders should consult the consuming component's implementation or extend their animation player to interpret these modes as needed.