2 unstable releases
0.2.0 | Nov 22, 2022 |
---|---|
0.1.0 | Nov 1, 2022 |
#1816 in Game dev
37KB
Bevy Notify
A bevy plugin wrapping the crate egui-notify
to allow sending toast messages utilizing events.
Usage
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"));
}
}
Setup
Add the plugin to your bevy app alongside the EguiPlugin
from bevy_egui. You also need to add a Toasts
resource to your app.
App::new().add_plugin(NotifyPlugin)
.add_plugin(EguiPlugin)
.insert_resource(Notifications(Toasts::default()));
lib.rs
:
bevy-notify
bevy-notify
is a bevy plugin wrapping egui_notify and
adding an event receiver to your bevy app. Toast notifications can then be send
in your bevy app at any point.
Examples
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"));
}
}
Dependencies
~32–46MB
~752K SLoC