Class AssetManager
Manages loading, monitoring, and access to assets.
class AssetManager
: dlib .core .ownership .Owner;
Constructors
| Name | Description |
|---|---|
this
(emngr, vfs, owner)
|
Constructor. |
Fields
| Name | Type | Description |
|---|---|---|
application
|
Application | The application object. Set by the scene that owns the AssetManager.
|
assetsByFilename
|
dlib | Dictionary of assets by filename. |
base64ImagePrefixes
|
dlib | Dictionary of default image filenames by MIME types. |
defaultTextureLoader
|
DefaultTextureLoader | Default texture loader. |
eventManager
|
EventManager | Event manager. |
fs
|
VirtualFileSystem | VFS to read files. |
hdrImageFactory
|
dlib | HDR image factory to load Radiance/HDR files. |
imageFactory
|
dlib | LDR image factory for the fallback image loading method. |
liveUpdate
|
bool | Is live reloading enabled for assets. |
liveUpdatePeriod
|
double | File status monitoring period in seconds. |
loadingThread
|
dlib | Asset loading thread. |
nextLoadingPercentage
|
float | Loading percentage in 0..1 range. |
stdfs
|
dlib | Physical FS for low-lever access. |
textureLoaders
|
dlib | Dictionary of texture loaders by file extension (including the dot). |
Methods
| Name | Description |
|---|---|
addAsset
(asset, name)
|
Adds an asset to the manager. |
assetExists
(name)
|
Checks if an asset exists by name. |
detectBase64Image
(uri)
|
Detects the image format and prefix for a base64-encoded image URI. |
fileExists
(filename)
|
Checks if a file exists in the virtual file system. |
getAsset
(name)
|
Gets an asset by name. |
isLoading
()
|
Returns true if assets are currently being loaded in a thread. |
loadAssetThreadSafePart
(asset, buffer, filename)
|
Loads the thread-safe part of an asset from a buffer. |
loadAssetThreadSafePart
(asset, istrm, filename)
|
Loads the thread-safe part of an asset from an input stream. |
loadAssetThreadSafePart
(asset, filename)
|
Loads the thread-safe part of an asset from a file. |
loadThreadSafePart
()
|
Starts the threaded loading process. |
loadThreadUnsafePart
()
|
Loads the thread-unsafe part of all assets. |
mountBoxFile
(filename)
|
Mounts a box file into the virtual file system. |
mountBoxFileDirectory
(filename, dir)
|
Mounts a directory from a box file into the virtual file system. |
mountDirectory
(dir)
|
Mounts a directory into the virtual file system. |
preloadAsset
(asset, name)
|
Preloads an asset (thread-safe and thread-unsafe parts). |
registerTextureLoader
(extension, loader)
|
Registers a texture loader for a file extension. |
registerTextureLoader
(extensions, loader)
|
Registers a texture loader for multiple file extensions. |
releaseAssets
()
|
Releases all assets and clears the manager. |
reloadAsset
(asset, filename)
|
Reloads an asset by object and filename. |
reloadAsset
(name)
|
Reloads an asset by name. |
removeAsset
(name)
|
Removes an asset by name. |
textureLoader
(extension)
|
Returns the texture loader for a given extension. |
updateMonitor
(dt)
|
Updates the asset monitor for live updates. |
monitorCheck
(filename, asset)
|
Checks for file changes and reloads assets if needed. |
Description
The AssetManager supports threaded loading,
live update monitoring, virtual file systems,
and registration of custom texture loaders.
It can mount directories and box files, and
detect base64-encoded images.