Skip to content

Corrosive-Games/bevy_toast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🍞 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

About

A bevy crate to easily show toast notifications to the player

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages