Ron file not detected by browser

35 Views Asked by At

I am trying to compile foxtrot app( with my modifications) to WASM. I have found most of the problems with Vulkan, OpenGl and WPU. Now I have another one. It seems that the browser doesn't see ron files. Here are the dependencies:

[dependencies]
bevy_kira_audio = "0.18"
bevy_asset_loader = { version = "0.19", features = ["progress_tracking"] }
bevy_common_assets = { version = "0.9", features = ["ron", "toml"] }
bevy_egui = "0.24"
serde = { version = "1", features = ["derive"] }
strum = "0.25"
strum_macros = "0.25"
ron = "0.8"
regex = "1"
chrono = "0.4"
glob = "0.3"
bitflags = "2"
iyes_progress = "0.10"
unicode-segmentation = "1"
anyhow = "1"
leafwing-input-manager = { version = "0.11", features = [] }
rand = { version = "0.8", features = ["small_rng", "nightly"] }
bevy_dolly = "0.0.2"
spew = "0.4"
bevy_mod_sysfail = "5"
seldom_fn_plugin = "0.5"
bevy_rapier3d = { version = "0.23", features = [ "serde-serialize", "wasm-bindgen"] }
bevy_editor_pls = { version = "0.7", optional = true }

image = { version = "0.24", default-features = false }
webbrowser = "0.8.13"

[dependencies.bevy]
version = "0.12"
features = [
    "png",
    "jpeg",
    "serialize"
]

[build-dependencies]
embed-resource = "2"

Missing assets

Here's a full screenshot of the browser, it's not a compile error.

asset error

Here's the moment where the asset is loaded:

pub(crate) fn loading_plugin(app: &mut App) {
    app.add_plugins(RonAssetPlugin::<SerializedLevel>::new(&["lvl.ron"]))

But it seems that the browser doesn't see these types of files.

1

There are 1 best solutions below

0
Wiktor Kujawa On

Ok, I found the solution. It was a problem with the bevy_asset_loader. It seems that something that is working on a desktop should work as well on the web. Here's the commented one (the previous implementation worked only on desktop) and the new one that works on both, but requires more argument paths.

// #[derive(AssetCollection, Resource, Clone)]
// pub(crate) struct LevelAssets {
//     #[asset(path = "levels", collection(typed, mapped))]
//     pub(crate) levels: HashMap<String, Handle<SerializedLevel>>,
// }

#[derive(AssetCollection, Resource, Clone)]
pub(crate) struct LevelAssets {
    #[asset(paths("levels/old_town.lvl.ron"), collection(typed, mapped))]
    pub(crate) levels: HashMap<String, Handle<SerializedLevel>>,
}