IAssets Type
Per-game asset loader/cache service.
Unlike the legacy Assets module API (which relies on module-level mutable state),
values of IAssets are safe to create per ElmishGame instance and can be stored
in a closure/ref and threaded through Elmish update/view.
Example
// In init:
let texture = Assets.texture "sprites/player" ctx
let font = Assets.font "fonts/main" ctx
// For custom assets:
let shader = Assets.getOrCreate "myShader" (fun gd -> new MyEffect(gd)) ctx
Instance members
| Instance member |
Description
|
Full Usage:
this.Clear
Modifiers: abstract |
Clears all caches (does not dispose ContentManager-managed assets). |
|
The ContentManager for loading compiled XNB assets.
|
Full Usage:
this.Create
Parameters:
string
factory : GraphicsDevice -> 'T
Returns: 'T
Modifiers: abstract Type parameters: 'T |
Creates and caches a custom asset using the provided factory. The factory receives the GraphicsDevice for creating GPU resources.
|
Full Usage:
this.Dispose
Modifiers: abstract |
Disposes any cached user-created assets implementing `IDisposable` and clears all caches. |
|
|
|
|
Full Usage:
this.Get
Parameters:
string
Returns: 'T voption
Modifiers: abstract Type parameters: 'T |
Gets a previously created custom asset by key.
|
Full Usage:
this.GetOrCreate
Parameters:
string
factory : GraphicsDevice -> 'T
Returns: 'T
Modifiers: abstract Type parameters: 'T |
Gets a cached asset or creates it if not present. This is the preferred method for custom assets - it's idempotent and ensures assets are created only once.
|
|
The GraphicsDevice for creating GPU resources.
|
|
|
|
|
|
Mibo