Skip to content

Commit

Permalink
Document setting "CARGO_MANIFEST_DIR" for asset root (bevyengine#1950)
Browse files Browse the repository at this point in the history
This was nowhere documented inside Bevy.
Should I also mention the use case of debugging a project?

Closes bevyengine#810

Co-authored-by: MinerSebas <[email protected]>
  • Loading branch information
MinerSebas and MinerSebas committed Apr 19, 2021
1 parent e29a899 commit 4583122
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
12 changes: 12 additions & 0 deletions crates/bevy_asset/src/asset_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<AssetPath<'a>>>(&self, path: P) -> Handle<T> {
self.load_untyped(path).typed()
}
Expand Down
10 changes: 8 additions & 2 deletions examples/asset/asset_loading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ fn setup(
meshes: Res<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
// 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");

Expand Down

0 comments on commit 4583122

Please sign in to comment.