IAssetLoader

Resolves serialized asset content by identifier and guarantees that repeated requests for the same asset return the same shared instance.

Remarks

The loader is the canonical owner of loaded asset instances. This is the mechanism by which DataAsset-style singletons remain consistent across AssetReference{TAsset} callers: every caller resolves the same GUID and therefore receives the same object, and a DataAssetAsset hands out one shared payload. Separate loaders never share instances.

Public Methods

LoadAsync

 Task<TAsset?> LoadAsync(Guid assetId)

Loads the asset with the given identifier, or returns the cached instance if already loaded. Returns null when the asset cannot be resolved or does not match the requested type.

Parameters:

  • assetId (Guid): The asset identifier.

Returns: Task<TAsset?>

LoadContentAsync

 Task<TData?> LoadContentAsync(Guid assetId)

Loads the shared payload of the DataAssetAsset with the given identifier. Returns null when the asset cannot be resolved or its payload is not a .

Parameters:

  • assetId (Guid): The asset identifier.

Returns: Task<TData?>

PreloadAsync

 Task PreloadAsync(IReadOnlyCollection<Guid> assetIds, CancellationToken cancellationToken = default)

Loads the given assets in parallel, including the shared payload of every DataAsset among them and of the DataAssets those reference, so later loads of them are cache hits.

Parameters:

  • assetIds (IReadOnlyCollection): The assets to load; unknown ids are skipped.
  • cancellationToken (CancellationToken): Stops waiting; loads already started still complete into the cache. (Default: default)

Returns: Task

PreloadLabelAsync

 Task PreloadLabelAsync(string label, CancellationToken cancellationToken = default)

Preloads every asset carrying label (see Labels).

Parameters:

  • label (string): The label to preload.
  • cancellationToken (CancellationToken): Stops waiting; loads already started still complete into the cache. (Default: default)

Returns: Task

TryGetLoaded

 bool TryGetLoaded(Guid assetId, TAsset? asset)

Returns the cached asset instance when one is available for the given identifier. Does not load the asset from disk.

Parameters:

  • assetId (Guid): The asset identifier.
  • asset (TAsset?): The cached asset, or null when not yet loaded or not of the expected type.

Returns: bool

Release

 void Release(Guid assetId)

Removes the cached instance for the given asset. Subsequent LoadAsync{TAsset} calls will reload from disk. Callers must ensure no live references to the released instance exist before calling this method.

Parameters:

  • assetId (Guid)