Skip to content

AnimationPlaybackManager<TKey>

ClassAssetInventoryAssetInventory.Editor
public class AnimationPlaybackManager<TKey>

Generic manager for handling multiple concurrent animation playbacks. Used by both Search grid and Project View overlay for animated preview playback.

public event Action<TKey, bool> OnAnimationLoaded

Event fired when an animation finishes loading (success or failure). Parameters: key, success

Returns

System.Action{{TKey},System.Boolean} — No return description is available.

public event Action<TKey> OnAnimationDisposed

Event fired when an animation is disposed. Parameter: key

Returns

System.Action{{TKey}} — No return description is available.

public int LoadedCount { get; }

Number of currently loaded and playing animations.

Returns

System.Int32 — No return description is available.

public int LoadingCount { get; }

Number of animations currently being loaded.

Returns

System.Int32 — No return description is available.

public int TotalActiveCount { get; }

Total count of loaded + loading animations.

Returns

System.Int32 — No return description is available.

public IEnumerable<TKey> LoadedKeys { get; }

Access to loaded animation player keys for iteration.

Returns

System.Collections.Generic.IEnumerable{{TKey}} — No return description is available.

public AnimationPlaybackManager(int maxConcurrentLoads = 3, Func<bool> isEnabledCheck = null, Func<int> maxLoadedCheck = null)

Creates a new AnimationPlaybackManager.

Parameters

Name Type Description
maxConcurrentLoads System.Int32 Maximum number of animations to load simultaneously.
isEnabledCheck System.Func{System.Boolean} Optional function to check if animation playback is still enabled. If provided and returns false, loading animations will be discarded.
maxLoadedCheck System.Func{System.Int32} Optional function that returns the maximum number of loaded animations allowed. If provided, QueueAnimation will return false when at the limit.

public bool IsLoaded(TKey key)

Checks if an animation is loaded for the given key.

Parameters

Name Type Description
key {TKey}

Returns

System.Boolean — No return description is available.

public bool IsLoading(TKey key)

Checks if an animation is currently being loaded for the given key.

Parameters

Name Type Description
key {TKey}

Returns

System.Boolean — No return description is available.

public bool IsActive(TKey key)

Checks if an animation is loaded or loading for the given key.

Parameters

Name Type Description
key {TKey}

Returns

System.Boolean — No return description is available.

public bool TryGetPlayer(TKey key, out AnimationPlayer player)

Gets the animation player for a key if loaded.

Parameters

Name Type Description
key {TKey}
player AssetInventory.AnimationPlayer

Returns

System.Boolean — No return description is available.

public Texture2D GetCurrentFrame(TKey key)

Gets the current frame texture for an animation if loaded.

Parameters

Name Type Description
key {TKey}

Returns

UnityEngine.Texture2D — No return description is available.

public bool QueueAnimation(TKey key, AssetInfo info)

Queues an animation for loading if not already loaded or loading.

Parameters

Name Type Description
key {TKey} The key to identify this animation.
info AssetInventory.AssetInfo The AssetInfo for the animation.

Returns

System.Boolean — True if queued, false if already loaded/loading or at max capacity.

public void ClearQueue()

Clears the load queue. Useful when scroll position changes significantly. Does not affect currently loading or loaded animations.

public void CancelLoading(TKey key)

Marks a key as no longer needed for loading. If the animation is currently loading, it will be discarded when complete.

Parameters

Name Type Description
key {TKey}
public void ProcessQueue()

Processes the load queue, starting new loads up to the concurrent limit. Should be called regularly (e.g., from Update loop).

public void DisposeAnimation(TKey key)

Disposes a single animation by key.

Parameters

Name Type Description
key {TKey}
public List<TKey> DisposeAll()

Disposes all animations and clears the queue.

Returns

System.Collections.Generic.List{{TKey}} — List of keys that were disposed (useful for restoring static previews).

UpdateVisibility(Func<TKey, bool>, Action)

Section titled “UpdateVisibility(Func<TKey, bool>, Action)”
public void UpdateVisibility(Func<TKey, bool> isVisible, Action<TKey> onDispose = null)

Updates which animations should be active based on a visibility check. Disposes animations that are no longer visible and queues new ones.

Parameters

Name Type Description
isVisible System.Func{{TKey},System.Boolean} Function to check if a key should still be visible/active.
onDispose System.Action{{TKey}} Optional callback when an animation is disposed for visibility reasons.
public static bool HasAnimatedPreview(AssetInfo info)

Checks if a preview file exists for the given AssetInfo.

Parameters

Name Type Description
info AssetInventory.AssetInfo

Returns

System.Boolean — No return description is available.