Skip to content

Commit

Permalink
Add note on AssetServer::load not being wasteful
Browse files Browse the repository at this point in the history
  • Loading branch information
alice-i-cecile committed Sep 5, 2024
1 parent a4b51d7 commit 480c2bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/bevy_asset/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
//!
//! The [`AssetServer`] is the main entry point for loading assets.
//! Typically, you'll use the [`AssetServer::load`] method to load an asset from disk, which returns a [`Handle`].
//! This handle will be used to instantiate various [`Component`](bevy_ecs::prelude::Component)s that require asset data to function,
//! Note that this method does not attempt to reload the asset if it has already been loaded: as long as the asset hasn't been dropped,
//! calling [`AssetServer::load`] on the same path will return the same handle.
//! The handle that's returned will be used to instantiate various [`Component`](bevy_ecs::prelude::Component)s that require asset data to function,
//! which will then be spawned into the world as part of an entity.
//!
//! If we later want to manipulate this asset data (such as for displaying a death animation), we have three options:
Expand Down
3 changes: 3 additions & 0 deletions crates/bevy_asset/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ impl AssetServer {
/// it returns a "strong" [`Handle`]. When the [`Asset`] is loaded (and enters [`LoadState::Loaded`]), it will be added to the
/// associated [`Assets`] resource.
///
/// Note that if the asset at this path is already loaded, this function will return the existing handle,
/// and will not waste work spawning a new load task.
///
/// In case the file path contains a hashtag (`#`), the `path` must be specified using [`Path`]
/// or [`AssetPath`] because otherwise the hashtag would be interpreted as separator between
/// the file path and the label. For example:
Expand Down

0 comments on commit 480c2bc

Please sign in to comment.