An experimental hot reload system for the bevy game engine. Inspired by DGriffin91's Ridiculous bevy hot reloading, it aims to resolve two particular problems I had with it: the ability to re-load arbitrary systems, and then ability to transform resource/component structures over time.
In your Cargo.toml
add the following:
```toml [features] hot = ["dexterousdeveloperexample/hot", "bevy/dynamic_linking"]
[lib] name = "libTHENAMEOFYOUR_GAME" path = "src/lib.rs" crate-type = ["rlib", "dylib"]
[dependencies] bevy = "0.11" dexterousdeveloperexample = "0.0.1" serde = "1" # If you want the serialization capacities ```
If your game is not a library yet, move all your main logic to lib.rs
rather than main.rs
. Then, in your main.rs
:
```rust
fn main() { libTHENAMEOFYOURGAME::bevymain(dexterous_developer::HotReloadOptions::default()); }
```
and in your lib.rs
, your main function should become:
```rust
pub fn bevymain(initial: InitialPlugins) { App::new().addplugins(initial.withdefaultplugins()) // This should replace the "DefaultPlugins", and you can use ".set()" on these as well. Use "withminimalplugins()" if you don't want the defaults. // ... and so on } ```
If you have a plugin where you want to add reloadable elements, add the following in the file defining the plugin:
```rust
impl Plugin for MyPlugin {
fn build(&self, app: &mut App) {
app
.setupreloadableelements::
fn reloadable(app: &mut ReloadableAppContents) { app .addsystems(Update, thissystemwillreload); }
```
You might also want the following in your .cargo/config.toml
:
```toml
config.toml
to enable "fast build" configuration. Please read the notes below.[target.x86_64-unknown-linux-gnu] linker = "clang" rustflags = ["-Clink-arg=-fuse-ld=lld", "-Zshare-generics=y"]
brew install llvm
[target.x86_64-apple-darwin] rustflags = [ "-C", "link-arg=-fuse-ld=/usr/local/opt/llvm/bin/ld64.lld", "-Zshare-generics=y", ]
[target.aarch64-apple-darwin] rustflags = [ "-C", "link-arg=-fuse-ld=/opt/homebrew/opt/llvm/bin/ld64.lld", "-Zshare-generics=y", ]
[target.x86_64-pc-windows-msvc] linker = "rust-lld.exe" rustflags = ["-Zshare-generics=n"]
[profile.dev] opt-level = 1
[profile.dev.package."*"] opt-level = 3
[profile.dev.package.gfx-backend-vulkan] opt-level = 3 debug-assertions = false
```