2个不稳定版本
| 0.2.0 | 2022年11月22日 | 
|---|---|
| 0.1.0 | 2022年11月1日 | 
#1816 in 游戏开发
37KB
Bevy Notify
一个Bevy插件,封装了egui-notify库,允许使用事件发送通知消息。
使用方法
fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugin(NotifyPlugin)
        .add_plugin(EguiPlugin)
        .insert_resource(Notifications(Toasts::default()))
        .add_system(notify_example_system)
        .run();
}
fn notify_example_system(key_input: Res<Input<KeyCode>>, mut events: ResMut<Events<Toast>>) {
    if key_input.just_pressed(KeyCode::Space) {
        events.send(Toast::success("Space pressed"));
    }
}
设置
将插件添加到您的Bevy应用程序中,与来自bevy_egui的EguiPlugin一起。您还需要向应用程序中添加一个Toasts资源。
App::new().add_plugin(NotifyPlugin)
    .add_plugin(EguiPlugin)
    .insert_resource(Notifications(Toasts::default()));
lib.rs:
bevy-notify
bevy-notify是一个Bevy插件,封装了egui_notify库,并向您的Bevy应用程序添加了事件接收器。然后可以在Bevy应用程序的任何位置发送通知消息。
示例
fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugin(NotifyPlugin)
        .add_plugin(EguiPlugin)
        .insert_resource(Notifications(Toasts::default()))
        .add_system(notify_example_system)
        .run();
}
   
fn notify_example_system(key_input: Res<Input<KeyCode>>, mut events: ResMut<Events<Toast>>) {
    if key_input.just_pressed(KeyCode::Space) {
        events.send(Toast::success("Space pressed"));
    }
}
依赖关系
~32–46MB
~752K SLoC