diff --git a/crates/bevy_asset/src/asset_server.rs b/crates/bevy_asset/src/asset_server.rs index be185e515b..7edbd337b6 100644 --- a/crates/bevy_asset/src/asset_server.rs +++ b/crates/bevy_asset/src/asset_server.rs @@ -212,6 +212,18 @@ impl AssetServer { load_state } + /// Loads an Asset at the provided relative path. + /// + /// The absolute Path to the asset is "ROOT/ASSET_FOLDER_NAME/path". + /// + /// By default the ROOT is the directory of the Application, but this can be overridden by + /// setting the `"CARGO_MANIFEST_DIR"` environment variable (see https://doc.rust-lang.org/cargo/reference/environment-variables.html) + /// to another directory. When the application is run through Cargo, then + /// `"CARGO_MANIFEST_DIR"` is automatically set to the root folder of your crate (workspace). + /// + /// The name of the asset folder is set inside the + /// [`AssetServerSettings`](crate::AssetServerSettings) resource. The default name is + /// `"assets"`. pub fn load<'a, T: Asset, P: Into>>(&self, path: P) -> Handle { self.load_untyped(path).typed() } diff --git a/examples/asset/asset_loading.rs b/examples/asset/asset_loading.rs index 5fe14b7272..a1952fbf36 100644 --- a/examples/asset/asset_loading.rs +++ b/examples/asset/asset_loading.rs @@ -15,8 +15,14 @@ fn setup( meshes: Res>, mut materials: ResMut>, ) { - // By default AssetServer will load assets from inside the "assets" folder - // For example, the next line will load "assets/models/cube/cube.gltf#Mesh0/Primitive0" + // By default AssetServer will load assets from inside the "assets" folder. + // For example, the next line will load "ROOT/assets/models/cube/cube.gltf#Mesh0/Primitive0", + // where "ROOT" is the directory of the Application. + // + // This can be overridden by setting the "CARGO_MANIFEST_DIR" environment variable (see + // https://doc.rust-lang.org/cargo/reference/environment-variables.html) + // to another directory. When the Application is run through Cargo, "CARGO_MANIFEST_DIR" is + // automatically set to your crate (workspace) root directory. let cube_handle = asset_server.load("models/cube/cube.gltf#Mesh0/Primitive0"); let sphere_handle = asset_server.load("models/sphere/sphere.gltf#Mesh0/Primitive0");