Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Bevy WASM
Mod your Bevy games with WebAssembly!
bevy_wasm_modding |
For games | |
bevy_wasm_modding_sys |
For mods | |
bevy_wasm_modding_shared |
For protocols |
See examples/cubes for a comprehensive example of how to use this.
Installation
rustup add target wasm32-unknown-unknown
optional (bad installation)
cargo clean
Now, to build 2 cubes in 2 separate mods In root directory,
cargo run -p cubes
Q. So where are the mods? A. In examples/cubes/cubes/assets
Q. So did I build the .wasm to wasm32-unknown-unknown? Yes. Cubes has a build.rs that builds them into the game. If you want to build the mod yourself to test In mod_with_bevy directory,
cargo build -p mod_with_bevy --target wasm32-unknown-unknown
However, when building your game (cubes/cubes/src/main.rs) it will automatically build the mods.
Protocol
Our protocol crate defines the two message types for communicating between the game and mods.
[]
= "0.19.2"
= { = "1.0", = ["derive"] }
use *;
use ;
use ;
/// The version of the protocol. Automatically set from the `CARGO_PKG_VERSION` environment variable.
pub const PROTOCOL_VERSION: Version = version!;
/// A message to be sent Mod -> Game.
/// A message to be sent Game -> Mod.
Game
Our game will import WasmPlugin from bevy_wasm, and use it to automatically send and receive messages with the mods.
[]
= "0.19.0"
= "0.19.2"
= { = "https://github.com/username/my_game_protocol" }
use ;
use *;
use ;
use ;
Mod
Our mod will import FFIPlugin from bevy_wasm_modding_sys, and use it to automatically send and receive messages with the game.
[]
= "0.19.2"
= { = "https://github.com/username/my_game_protocol" }
use *;
use ;
use ;
pub unsafe extern "C"
Sharing Resources
Protocol:
Game:
new
...
.insert_resource
.add_plugins
.add_systems
...
Mod:
new
...
.add_plugins
.add_systems
.add_systems
...
See examples/shared_resources for a full example.
Roadmap
| ✅ | wasmtime runtime in games |
| ✅ | Send messages from mods to game |
| ✅ | Send messages from game to mods |
| ✅ | Multi-mod support |
| ✅ | Time keeping |
| ✅ | Protocol version checking |
| ✅ | Extern Resource |
| ✅ | Startup system mod loading |
| ✅ | Direct update control |
| ✅ | Mod unloading |
| ✅ | Mod discrimination (events aren't broadcast all) |
| ✅ | Browser support |
| ⬜ | Extern Query |
| ⬜ | Synced time |
| ⬜ | Mod hotloading |
| ⬜ | Automatic component syncing |
License
Bevy WASM modding is free, open source and permissively licensed! Except where noted (below and/or in individual files), all code in this repository is dual-licensed under either:
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
at your option. This means you can select the license you prefer! This dual-licensing approach is the de-facto standard in the Rust ecosystem and there are very good reasons to include both.
Your contributions
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.