pub struct AssetManager { /* private fields */ }Expand description
The asset manager handles loading, caching, and lifecycle of game assets.
§Example
let mut assets = AssetManager::new(AssetConfig::default());
// Load assets
let player_tex = assets.load_image("sprites/player.png");
let bg_music = assets.load_sound("music/background.ogg");
// Use assets
// draw_texture(player_tex.unwrap(), ...);
// In update loop (for hot-reload):
assets.check_hot_reload();Implementations§
Source§impl AssetManager
impl AssetManager
Sourcepub fn new(config: AssetConfig) -> Self
pub fn new(config: AssetConfig) -> Self
Create a new asset manager.
Sourcepub fn load_image(
&mut self,
path: &str,
) -> Result<AssetHandle<ImageAsset>, String>
pub fn load_image( &mut self, path: &str, ) -> Result<AssetHandle<ImageAsset>, String>
Load an image from disk.
Returns a handle to the cached image, or an error.
Sourcepub fn unload_image(&mut self, path: &str)
pub fn unload_image(&mut self, path: &str)
Unload an asset by path.
Sourcepub fn check_hot_reload(&mut self)
pub fn check_hot_reload(&mut self)
Check for modified files and reload if hot-reload is enabled.
Sourcepub fn total_image_bytes(&self) -> usize
pub fn total_image_bytes(&self) -> usize
Total bytes of loaded image data.
Sourcepub fn image_count(&self) -> usize
pub fn image_count(&self) -> usize
Number of cached images.
Auto Trait Implementations§
impl Freeze for AssetManager
impl RefUnwindSafe for AssetManager
impl Send for AssetManager
impl Sync for AssetManager
impl Unpin for AssetManager
impl UnsafeUnpin for AssetManager
impl UnwindSafe for AssetManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more