#toast #bevy #bevy-plugin #notifications

bevy_toast

A bevy plugin to easily show toast notifications to the player

2 releases

0.1.1 Mar 10, 2022
0.1.0 Mar 10, 2022

#1207 in Game dev

MIT license

335KB
205 lines

🍞 Bevy Toast

License: MIT/Apache Doc Crate Coverage Status Bevy tracking

A bevy plugin to easily show toast notifications to the player

Features

  • Add in-game notifications to your bevy project
  • Customize the duration and the text of the toast

Demo

The source code for the following example is available here: /examples/hello_world.rs

Hello world toast GIF

Usage

Plugin setup

Add the following plugins to your project:

use bevy_tweening::TweeningPlugin;
use bevy_toast::ToastPlugin;

fn main() {
    App::new()
        .add_plugin(TweeningPlugin)
        .add_plugin(ToastPlugin)
        .run();
}

Send a toast 🍞

Sending a Toast is a simple as sending a ShowToast event:

// send a toast when pressing 'E'
fn keyboard_handler(
    keyboard: Res<Input<KeyCode>>,
    toast_sender: EventWriter<ShowToast>,
) {
    if keyboard.just_pressed(KeyCode::E) {
        toast_evt.send(ShowToast {
            title: "Achievement reached!".to_string(),
            subtitle: "You pressed 'E'".to_string(),
            duration: Duration::from_secs(2),
        });
    }
}

Compatible versions

bevy bevy_toast
0.6 0.1

Dependencies

~38–52MB
~1M SLoC