我正在尝试将 Foxtrot 应用程序(经过我的修改)编译为 WASM。我发现了 Vulkan、OpenGl 和 WPU 的大部分问题。现在我又有了一个。浏览器似乎看不到 ron 文件。 以下是依赖项:
[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"
这是浏览器的完整截图,这不是编译错误。
这是资源加载的时刻:
pub(crate) fn loading_plugin(app: &mut App) {
app.add_plugins(RonAssetPlugin::<SerializedLevel>::new(&["lvl.ron"]))
但是浏览器似乎看不到这些类型的文件。
好的,我找到了解决方案。这是 bevy_asset_loader 的问题。似乎在桌面上运行的东西也应该在网络上运行。 这是带注释的实现(之前的实现仅适用于桌面)和新的实现,适用于两者,但需要更多参数路径。
// #[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>>,
}