#bevy #hot-reload #ui #game-engine

dexterous_developer_macros

Rust的模块化热重载系统

15个版本

0.2.0 2024年2月18日
0.1.0 2023年12月2日
0.0.12 2023年11月16日
0.0.11 2023年9月26日
0.0.8 2023年8月28日

#21#hot-reload

Download history 28/week @ 2024-03-11 8/week @ 2024-03-18 41/week @ 2024-04-01 1/week @ 2024-04-08 10/week @ 2024-04-15 13/week @ 2024-04-22 7/week @ 2024-04-29 10/week @ 2024-05-06 3/week @ 2024-05-13 20/week @ 2024-05-20 14/week @ 2024-05-27 18/week @ 2024-06-03 18/week @ 2024-06-10 10/week @ 2024-06-17 17/week @ 2024-06-24

每月 64次下载
用于 dexterous_developer_inter…

MIT/Apache

10KB
71

Dexterous Developer

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

bevy游戏引擎的一个实验性热重载系统。受 DGriffin91的Ridiculous bevy热重载 的启发 - 添加了重新加载任意系统的能力,以及随着时间的推移转换资源/组件结构的能力。

更详细的文档可在以下位置找到: https://lee-orr.github.io/dexterous_developer/

功能

  • 明确定义你的游戏可重载的区域 - 这可以包括系统、组件、状态、事件和资源(有一些限制)
  • 在重载时将资源重置为默认值或预先确定的值
  • 序列化/反序列化你的可重载资源 & 组件,允许你根据它们与反序列化器的兼容性进化它们的模式(使用 rmp_serde)
  • 标记实体以在热重载时移除
  • 热重载后运行系统
  • 创建在进入/退出状态或热重载时设置和拆除的函数
  • 仅在显式启用时将热重载能力包含在你的构建中 - 例如,通过使用CLI启动器
  • 跨平台/跨设备热重载 - 在开发环境中运行一个 "热重载服务器",并在其他地方执行应用程序。为了获得最佳效果,开发环境应该是Linux设备或基于Linux的开发容器,但也可以配置为在Windows或mac上直接运行 - 尽管可靠性较低。由于可以通过设置Linux来托管docker-in-docker环境,因此跨编译直接在Windows/mac上不是优先考虑的事项,因为它们始终可以设置为托管Linux。 此功能在当前版本中不起作用,但将在将来重新实现

已知问题

  • 在移动或WASM上无法工作

安装

通过运行以下命令获取CLI:cargo install dexterous_developer_cli

你将能够在终端中运行 dexterous_developer_cli run 来运行你的dexterous版本代码。

在你的 Cargo.toml 中添加以下内容

[lib]
name = "lib_THE_NAME_OF_YOUR_GAME"
path = "src/lib.rs"
crate-type = ["rlib"]

[dependencies]
bevy = "0.13"
dexterous_developer = "0.1.1"
serde = "1" # If you want the serialization capacities

[package.metadata]
hot_reload_features = ["bevy/dynamic_linking", "bevy/embedded_watcher"] # this injects these features into the build, enabling the use of bevy's dynamic linking and asset hot reload capacity.

如果你的游戏还不是库,请将所有主要逻辑移动到lib.rs,而不是main.rs。然后,在你的main.rs中 - 调用bevy_main函数

fn main() {
    lib_NAME_OF_YOUR_GAME::bevy_main();
}

并在你的lib.rs中,你的主函数应该变为

#[hot_bevy_main]
pub fn bevy_main(initial_plugins: impl InitialPlugins) {
    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
}

如果你有一个插件,你想在其中添加可重新加载的元素,请在定义插件的文件中添加以下内容


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

#[dexterous_developer_setup]
fn reloadable(app: &mut ReloadableAppContents) {
    app
        .add_systems(Update, this_system_will_reload);
}

Bevy版本支持

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

依赖项

~1.5–7MB
~43K SLoC