IAssetCache Type
Backend-neutral generic asset cache: stores arbitrary user-created assets by string key, with create-or-get semantics.
This is the shareable subset of asset caching. Backend-specific asset services
(e.g. raylib's IAssets) extend this interface to add typed loaders that
return native GPU/resource handles (Texture2D, Font, Sound,
etc.), which are inherently backend-specific.
Example
/// Each backend registers its own IAssets (which inherits IAssetCache)
/// under the IAssets key, so resolve via the backend's IAssets type:
let cache = GameContext.getService<IAssets> ctx
let config = cache.GetOrCreate("gameConfig", fun () -> loadConfig())
Each backend registers its own IAssets (which inherits IAssetCache)
under the IAssets key, so resolve via the backend's IAssets type:
Instance members
| Instance member |
Description
|
Full Usage:
this.Clear
Modifiers: abstract |
Clears all caches (does not dispose GPU resources). |
Full Usage:
this.Create
Parameters:
string
factory : unit -> 'T
Returns: 'T
Modifiers: abstract Type parameters: 'T |
Creates and caches a custom asset using the provided factory.
|
Full Usage:
this.Dispose
Modifiers: abstract |
Disposes all cached assets and clears 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 : 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.
|
Mibo