Skip to content

IAssetLoader.PreloadAsync(AssetManifest, IProgress, CancellationToken) Method

Resolves all AssetRef<T> fields declared on manifest in parallel, reporting progress as each asset completes. Call this in OnLoadAsync. Assets are safe to access from OnEnter onwards.

System.Threading.Tasks.Task PreloadAsync(Brine2D.Assets.AssetManifest manifest, System.IProgress<Brine2D.Assets.AssetLoadProgress>? progress=null, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));

Parameters

manifest AssetManifest

progress System.IProgress<AssetLoadProgress>

cancellationToken System.Threading.CancellationToken

Returns

System.Threading.Tasks.Task

Remarks

Partial failure: If some assets fail while others succeed, an System.AggregateException is thrown containing only the failures. Successfully loaded assets remain cached and their Value is set. Calling PreloadAsync again on the same manifest retries only the unresolved refs (resolved refs short-circuit), making transient errors (network timeouts, file locks) recoverable without reloading the entire manifest.

If the failure is non-recoverable, call Unload(AssetManifest) to release the partially loaded assets before retrying or transitioning scenes.

Cancellation: If the cancellationToken is triggered, the manifest tracking and its reference counts are rolled back automatically so no phantom references remain. A subsequent call to PreloadAsync on the same manifest will re-track and retry from scratch.