From 6abb67980c0510db065a3e8115caa4359ca7d05e Mon Sep 17 00:00:00 2001 From: Thierry Berger Date: Sun, 17 Jul 2022 14:46:11 +0200 Subject: [PATCH] BEVY_ASSET_ROOT with higher priority than CARGO_MANIFEST_DIR + updated doc --- crates/bevy_asset/src/io/file_asset_io.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/bevy_asset/src/io/file_asset_io.rs b/crates/bevy_asset/src/io/file_asset_io.rs index 5d1b76e8da5989..e4f9a57bba0cdc 100644 --- a/crates/bevy_asset/src/io/file_asset_io.rs +++ b/crates/bevy_asset/src/io/file_asset_io.rs @@ -60,13 +60,15 @@ impl FileAssetIo { /// 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 + /// If a `BEVY_ASSET_ROOT` environment variable is set, then its value will be used. + /// + /// Else 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`. pub fn get_base_path() -> PathBuf { - if let Ok(manifest_dir) = env::var("CARGO_MANIFEST_DIR") { - PathBuf::from(manifest_dir) - } else if let Ok(env_bevy_asset_root) = env::var("BEVY_ASSET_ROOT") { + if let Ok(env_bevy_asset_root) = env::var("BEVY_ASSET_ROOT") { PathBuf::from(env_bevy_asset_root) + } else if let Ok(manifest_dir) = env::var("CARGO_MANIFEST_DIR") { + PathBuf::from(manifest_dir) } else { env::current_exe() .map(|path| {