Class AssetManager

Manages loading, monitoring, and access to assets.

class AssetManager
  : dlib.core.ownership.Owner;

Constructors

NameDescription
this (emngr, vfs, owner) Constructor.

Fields

NameTypeDescription
application ApplicationThe application object. Set by the scene that owns the AssetManager.
assetsByFilename dlib.container.dict.Trie!(dagon.resource.asset.Asset,string)Dictionary of assets by filename.
base64ImagePrefixes dlib.container.dict.Trie!(string,string)Dictionary of default image filenames by MIME types.
defaultTextureLoader DefaultTextureLoaderDefault texture loader.
eventManager EventManagerEvent manager.
fs VirtualFileSystemVFS to read files.
hdrImageFactory dlib.image.hdri.UnmanagedHDRImageFactoryHDR image factory to load Radiance/HDR files.
imageFactory dlib.image.unmanaged.UnmanagedImageFactoryLDR image factory for the fallback image loading method.
liveUpdate boolIs live reloading enabled for assets.
liveUpdatePeriod doubleFile status monitoring period in seconds.
loadingThread dlib.core.thread.ThreadAsset loading thread.
nextLoadingPercentage floatLoading percentage in 0..1 range.
stdfs dlib.filesystem.stdfs.StdFileSystemPhysical FS for low-lever access.
textureLoaders dlib.container.dict.Trie!(dagon.resource.asset.TextureLoader,string)Dictionary of texture loaders by file extension (including the dot).

Methods

NameDescription
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.