lee-orr / dexterous_developer

A hot reload system for the Bevy game engine
Apache License 2.0
183 stars 4 forks source link

Dexterous Developer

GitHub Workflow Status (with event) GitHub Workflow Status (with event) crates.io cli

A modular hot-reload system for Rust.

Docs for the latest release are available at: https://lee-orr.github.io/dexterous_developer/

You can also find docs for the latest pre-release and docs for the main branch

Features

Bevy Specific

Future Work

Installation

Install the CLI by running: cargo install dexterous_developer_cli@0.4.0-alpha.3. This installs 2 command line utilities:

Setup

You'll also need to add the appropriate dexterous developer adapter to your library's dependencies, and set up the "hot" feature. For example, if you are using bevy:

[features]
hot = ["bevy_dexterous_developer/hot"]

[dependencies]
bevy = "0.14"
bevy_dexterous_developer = { version = "0.4.0-alpha.3"}
serde = "1" # If you want the serialization capacities

Finally, you'll need to set up a Dexterous.toml file, that helps define some of the necessary elements - such as which folders should be watched for changes, and what features should be enabled. See the example file in this repository or the book for more info.

Bevy Setup

In your main.rs, your main function should become:

reloadable_main!((initial_plugins) {
    App::new()
        .add_plugins(initial_plugins.initialize::<DefaultPlugins>()) // You can use either DefaultPlugins or MinimnalPlugins here, and use "set" on this as you would with them
    // Here you can do what you'd normally do with app
    // ... and so on
});

If you have a plugin where you want to add reloadable elements, add the following in the file defining the plugin:


impl Plugin for MyPlugin {
    fn build(&self, app: &mut App) {
        app
            .setup_reloadable_elements::<reloadable>();
    }
}

reloadable_scope!(reloadable(app) {
    app
        .add_systems(Update, this_system_will_reload);
})

The Simple Visual example shows the basic use of the library, and the book has more info as well.

Running with Hot Reload

To run a hot-reloaded app locally, cargo install and run dexterous_developer_cli (optionally passing in a specific package or example).

To run the app on a different machine (with the same platform), cargo install dexterous_developer_cli on both machines, and then:

Running or Building Without Hot Reload

To build or run the non-hot-reloadable version of your app, just remember to avoid including the hot feature, since it's designed to work only inside a reloadable library!.

Inspiration

Initial inspiration came from DGriffin91's Ridiculous bevy hot reloading

Bevy Version Support

Bevy Dexterous Developer
0.14 >= 0.3
0.13 = 0.2
0.12 0.0.12, 0.1
0.11 <= 0.0.11