AssetManifest Class
Definition
Namespace: Brine2D.Assets
Base class for typed asset manifests. Subclass it, declare your assets as AssetRef<T> fields, then pass the manifest to PreloadAsync\(AssetManifest, IProgress<AssetLoadProgress>, CancellationToken\) in your scene's OnLoadAsync.
Inheritance System.Object → AssetManifest
Example
C#
public class LevelAssets : AssetManifest
{
public readonly AssetRef<ITexture> Tileset = Texture("assets/images/tileset.png", TextureScaleMode.Nearest);
public readonly AssetRef<ITexture> Player = Texture("assets/images/player.png");
public readonly AssetRef<ISoundEffect> Jump = Sound("assets/audio/jump.wav");
public readonly AssetRef<IMusic> BgMusic = Music("assets/audio/level1.ogg");
public readonly AssetRef<IFont> HUDFont = Font("assets/fonts/hud.ttf", size: 20);
}
| Methods | |
|---|---|
| Font\(string, int\) | Declares a font asset. Size is part of the identity: Font\("ui\.ttf", 16\) and Font\("ui\.ttf", 32\) are two independent cached entries. |
| GetAll() | Returns all AssetRef<T> fields declared on this manifest instance. FieldInfo is cached per concrete type; resolved refs are cached per instance. |
| GetUniqueKeys() | Returns the deduplicated set of RefCountKeys for this manifest. Computed once from GetAll() and cached for the lifetime of the instance, so Brine2D.Assets.AssetCache.PreloadAsync\(Brine2D\.Assets\.AssetManifest,System\.IProgress\{Brine2D\.Assets\.AssetLoadProgress\},System\.Threading\.CancellationToken\) and Brine2D.Assets.AssetCache.Unload\(Brine2D\.Assets\.AssetManifest\) can iterate unique keys without allocating on every call. |
| Music\(string\) | Declares a music asset \(streamed\). |
| Sound\(string\) | Declares a sound effect asset \(short, in\-memory\). |
| Texture\(string, TextureScaleMode\) | Declares a texture asset. |