#bevy #web #gamedev

bevy_web_popups

Allows to trigger web/dom based popups/alerts and textinput in bevy

5 releases

0.2.1 Sep 12, 2024
0.2.0 Sep 10, 2024
0.1.2 Sep 7, 2024
0.1.1 Aug 29, 2024
0.1.0 Aug 29, 2024

#544 in Game dev

Download history 248/week @ 2024-08-29 449/week @ 2024-09-05 256/week @ 2024-09-12 31/week @ 2024-09-19 36/week @ 2024-09-26 52/week @ 2024-10-03

423 downloads per month

MIT license

2MB
188 lines

bevy_web_popups

crates.io docs.rs discord

Allows to trigger web/dom based popups/alerts and textinput in bevy using wasm-bindgen's web_sys. It is fully customizable but comes with a batteries included default style (see demo below).

See also: bevy_ios_iap, bevy_ios_gamecenter, bevy_ios_notifications, bevy_ios_alerts, bevy_ios_review, bevy_ios_impact & bevy_device_lang

See the crate in action in TinyTakeoff:

demo

Features

  • window.alert()
  • popup dialog with background darkening, textinput, cancel and ok button (fully customizable)

Usage

Add dependency: bevy_web_popups = "0.1"

Initialize Bevy Plugin:

// request initialisation right on startup
app.add_plugins(WebAlertsPlugin);
fn bevy_system() {
    // trigger native browser alert message popup
    bevy_web_popups::alert("important msg");

    // trigger complex text input popup with a custom title, custom labels for the buttons and asking to spawn default css classes instead of specifying them ourselfs
    bevy_web_popups::show_textinput("set nickname:", "ok", "cancel", true);
}

// system processing events coming from the web plugin
fn process_events(
    mut events: EventReader<WebAlertResponse>,
) {
    for e in events.read() {
        if let WebAlertResponse::InputOk(text) = e {
            info!("user confirmed with text: {text}");
        }
    }
}

Bevy version support

bevy bevy_ios_iap
0.13 0.2,main
0.13 0.1

License

All code in this repository is dual-licensed under either:

at your option. This means you can select the license you prefer.

Your contributions

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~24MB
~445K SLoC