Reccomend using AssetPlugin.file_path instead of CARGO_MANIFEST_DIR (#15176)

Fixes #15175.

One question I have: I see that the scene_viewer example uses the
CARGO_MANIFEST_DIR. Should that line be removed, or would that break the
tool?

1fd478277e/examples/tools/scene_viewer/main.rs (L40)
This commit is contained in:
Wybe Westra 2024-09-13 18:16:23 +02:00 committed by GitHub
parent 1b1105e327
commit ae80a20690
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 6 deletions

View file

@ -51,8 +51,7 @@ impl FileAssetReader {
/// Returns the base path of the assets directory, which is normally the executable's parent
/// directory.
///
/// If the `CARGO_MANIFEST_DIR` environment variable is set, then its value will be used
/// instead. It's set by cargo when running with `cargo run`.
/// To change this, set [`AssetPlugin.file_path`].
pub fn get_base_path() -> PathBuf {
get_base_path()
}

View file

@ -19,10 +19,7 @@ fn setup(
// For example, the next line will load GltfAssetLabel::Primitive{mesh:0,primitive:0}.from_asset("ROOT/assets/models/cube/cube.gltf"),
// 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.
// This can be overridden by setting [`AssetPlugin.file_path`].
let cube_handle = asset_server.load(
GltfAssetLabel::Primitive {
mesh: 0,