Skip to content

Commit

Permalink
fix: make web builds load assets relative to the path the game is hos…
Browse files Browse the repository at this point in the history
…ted under. (#235)
  • Loading branch information
zicklag authored Oct 15, 2023
1 parent 2335ab6 commit 155636c
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 84 deletions.
25 changes: 0 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion framework_crates/bones_bevy_renderer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ version = "0.11"
directories = "5.0"

[target.'cfg(target_arch = "wasm32")'.dependencies]
web-sys = { version = "0.3", features = ["Window", "Storage"] }
web-sys = { version = "0.3", features = ["Window", "Storage", "Location"] }
5 changes: 4 additions & 1 deletion framework_crates/bones_bevy_renderer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,10 @@ impl BonesBevyRenderer {
}
#[cfg(target_arch = "wasm32")]
{
let io = bones::WebAssetIo::new("/assets/");
let window = web_sys::window().unwrap();
let path = window.location().pathname().unwrap();
let base = path.rsplit_once('/').map(|x| x.0).unwrap_or(&path);
let io = bones::WebAssetIo::new(&format!("{base}/assets"));
asset_server.set_io(io);
}

Expand Down
1 change: 0 additions & 1 deletion framework_crates/bones_schema/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,3 @@ required-features = ["glam"]

[dev-dependencies]
serde_yaml = "0.9"
trybuild = "1.0"
6 changes: 0 additions & 6 deletions framework_crates/bones_schema/tests/trybuild.rs

This file was deleted.

38 changes: 0 additions & 38 deletions framework_crates/bones_schema/tests/trybuild_fail/schema_ptr.rs

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.71
1.73

0 comments on commit 155636c

Please sign in to comment.