bevy_toast

Crates.iobevy_toast
lib.rsbevy_toast
version0.1.1
sourcesrc
created_at2022-03-10 14:22:56.13086
updated_at2022-03-10 14:26:53.483012
descriptionA bevy plugin to easily show toast notifications to the player
homepage
repositoryhttps://github.com/NightlySide/bevy_toast
max_upload_size
id547638
size402,577
NightlySide (NightlySide)

documentation

README

🍞 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
Commit count: 8

cargo fmt