Skip to content

Commit 94f5d19

Browse files
committed
Doc AssetServer::load() is async (#3129)
# Objective Document that `AssetServer::load()` is asynchronous. ## Solution Document that `AssetServer::load()` is asynchronous, and that the asset will not be immediately available once the call returns. Instead, explain that the user must call `AssetServer::get_load_state()` to monitor the loading state of an asset.
1 parent ac06ea3 commit 94f5d19

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

crates/bevy_asset/src/asset_server.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ impl AssetServer {
213213
load_state
214214
}
215215

216-
/// Loads an Asset at the provided relative path.
216+
/// Queue an [`Asset`] at the provided relative path for asynchronous loading.
217217
///
218218
/// The absolute Path to the asset is "ROOT/ASSET_FOLDER_NAME/path".
219219
///
@@ -226,6 +226,10 @@ impl AssetServer {
226226
/// The name of the asset folder is set inside the
227227
/// [`AssetServerSettings`](crate::AssetServerSettings) resource. The default name is
228228
/// `"assets"`.
229+
///
230+
/// The asset is loaded asynchronously, and will generally not be available by the time
231+
/// this calls returns. Use [`AssetServer::get_load_state`] to determine when the asset is
232+
/// effectively loaded and available in the [`Assets`] collection.
229233
#[must_use = "not using the returned strong handle may result in the unexpected release of the asset"]
230234
pub fn load<'a, T: Asset, P: Into<AssetPath<'a>>>(&self, path: P) -> Handle<T> {
231235
self.load_untyped(path).typed()

0 commit comments

Comments
 (0)