From ddc9f415191c286763d0058101cfe1754ca6d577 Mon Sep 17 00:00:00 2001 From: atlv Date: Mon, 12 May 2025 06:10:32 -0400 Subject: [PATCH] fix windows wasm embedded assets (#19139) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Objective - Fix #14246 ## Solution - If building for wasm windows, add a bit of code that replaces `\\` with `/` in the `file!()` arg ## Testing - Used MRE https://github.com/janhohenheim/asset-crash --------- Co-authored-by: François Mockers --- crates/bevy_asset/src/io/embedded/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/bevy_asset/src/io/embedded/mod.rs b/crates/bevy_asset/src/io/embedded/mod.rs index 13610531e2..e63d415342 100644 --- a/crates/bevy_asset/src/io/embedded/mod.rs +++ b/crates/bevy_asset/src/io/embedded/mod.rs @@ -168,6 +168,13 @@ pub fn _embedded_asset_path( file_path: &Path, asset_path: &Path, ) -> PathBuf { + let file_path = if cfg!(not(target_family = "windows")) { + // Work around bug: https://github.com/bevyengine/bevy/issues/14246 + // Note, this will break any paths on Linux/Mac containing "\" + PathBuf::from(file_path.to_str().unwrap().replace("\\", "/")) + } else { + PathBuf::from(file_path) + }; let mut maybe_parent = file_path.parent(); let after_src = loop { let Some(parent) = maybe_parent else {