Header menu logo Mibo.Raylib

IAssets Type

Per-game asset loader/cache service.

Provides cached loading for textures, fonts, sounds, models, and shaders from loose files (no content pipeline). Also supports generic typed cache for custom asset types.

Example

 let assets = GameContext.getService<IAssets> ctx
 let tex = assets.Texture "sprites/player.png"
 let font = assets.Font "fonts/main.ttf"
 let config = assets.GetOrCreate "gameConfig" (fun () -> loadConfig())
val assets: obj
val tex: obj
val font: obj
val config: obj

Instance members

Instance member Description

this.Clear

Full Usage: this.Clear

Modifiers: abstract

Clears all caches (does not dispose GPU resources).

this.Create

Full Usage: this.Create

Parameters:
    key : string
    factory : unit -> 'T

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

Creates and caches a custom asset using the provided factory.

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

this.Dispose

Full Usage: this.Dispose

Modifiers: abstract

Disposes all cached assets and clears caches.

this.Font

Full Usage: this.Font

Parameters:
    path : string

Returns: Font
Modifiers: abstract

Loads and caches a Font from file.

path : string
Returns: Font

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:
    key : string
    factory : unit -> '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 - idempotent, ensures assets are created only once.

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

this.Model

Full Usage: this.Model

Parameters:
    path : string

Returns: Model
Modifiers: abstract

Loads and caches a Model from file.

path : string
Returns: Model

this.Sound

Full Usage: this.Sound

Parameters:
    path : string

Returns: Sound
Modifiers: abstract

Loads and caches a Sound from file.

path : string
Returns: Sound

this.Texture

Full Usage: this.Texture

Parameters:
    path : string

Returns: Texture2D
Modifiers: abstract

Loads and caches a Texture2D from file.

path : string
Returns: Texture2D

Type something to start searching.