Header menu logo Mibo

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
val texture: obj
val font: obj
val shader: obj

Instance members

Instance member Description

this.Clear

Full Usage: this.Clear

Modifiers: abstract

Clears all caches (does not dispose ContentManager-managed assets).

this.Content

Full Usage: this.Content

Returns: ContentManager
Modifiers: abstract

The ContentManager for loading compiled XNB assets.

Returns: ContentManager

this.Create

Full Usage: this.Create

Parameters:
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.

key : string
factory : GraphicsDevice -> 'T
Returns: 'T

this.Dispose

Full Usage: this.Dispose

Modifiers: abstract

Disposes any cached user-created assets implementing `IDisposable` and clears all caches.

this.Effect

Full Usage: this.Effect

Parameters:
    path : string

Returns: Effect
Modifiers: abstract

Loads and caches a Effect from the content pipeline.

path : string
Returns: Effect

this.Font

Full Usage: this.Font

Parameters:
    path : string

Returns: SpriteFont
Modifiers: abstract

Loads and caches a SpriteFont from the content pipeline.

path : string
Returns: SpriteFont

this.Get

Full Usage: this.Get

Parameters:
    key : string

Returns: 'T voption
Modifiers: abstract
Type parameters: 'T

Gets a previously created custom asset by key.

key : string
Returns: 'T voption

this.GetOrCreate

Full Usage: this.GetOrCreate

Parameters:
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.

key : string
factory : GraphicsDevice -> 'T
Returns: 'T

this.GraphicsDevice

Full Usage: this.GraphicsDevice

Returns: GraphicsDevice
Modifiers: abstract

The GraphicsDevice for creating GPU resources.

Returns: GraphicsDevice

this.Model

Full Usage: this.Model

Parameters:
    path : string

Returns: Model
Modifiers: abstract

Loads and caches a 3D Model from the content pipeline.

path : string
Returns: Model

this.Sound

Full Usage: this.Sound

Parameters:
    path : string

Returns: SoundEffect
Modifiers: abstract

Loads and caches a SoundEffect from the content pipeline.

path : string
Returns: SoundEffect

this.Texture

Full Usage: this.Texture

Parameters:
    path : string

Returns: Texture2D
Modifiers: abstract

Loads and caches a Texture2D from the content pipeline.

path : string
Returns: Texture2D

Type something to start searching.