#bevy-ui #popup #ui-component #bevy-plugin #notifications #user-input #modal

bevy_text_popup

Easily create temporary text pop-up nodes in the Bevy game engine

7 releases (4 breaking)

new 0.5.2 Dec 6, 2024
0.5.1 Dec 6, 2024
0.4.0 Jul 29, 2024
0.3.0 May 9, 2024
0.1.0 Aug 24, 2023

#444 in Game dev

Download history 9/week @ 2024-09-20 9/week @ 2024-09-27 4/week @ 2024-10-04 3/week @ 2024-10-11 3/week @ 2024-11-01 1/week @ 2024-11-08 49/week @ 2024-11-29

60 downloads per month

MIT/Apache

635KB
408 lines

Bevy Text Popup

Bevy Text Popup Latest version Documentation MIT Apache

Bevy plugin to easily create UI text popups with events.

Popups are meant to be short-lived and on top of all other UI components.

Useful for notifications and prompting user input.

Current Customization Options:

  • Font: cargo run --example custom_font
  • Background: Color and Transparency (image background to come)
  • Border: cargo run --example border
  • Buttons: cargo run --example buttons
  • Timeouts: Dismiss automatically after X seconds
  • Modal: cargo run --example modal

Upcoming Customization Options:

  • Dismiss: Click anywhere to dismiss, X close button, etc.
  • Input: Allow for user input.
  • Hover/Click: Color change on button/popup hover/click.
  • Animations: Open/Close/Dismiss/Click/etc.

Examples

This example will display a modal popup for 10s with a 'Close' button.

use bevy::prelude::*;
use bevy_text_popup::{TextPopupEvent, TextPopupPlugin, TextPopupTimeout, TextPopupButton};

fn main() {
    App::new()
        .add_plugins((DefaultPlugins, TextPopupPlugin))
        .add_systems(Startup, setup)
        .run();
}

fn setup(mut commands: Commands, mut text_popup_events: EventWriter<TextPopupEvent>) {
    commands.spawn(Camera2d::default());

    text_popup_events.send(TextPopupEvent {
        content: "Modal Example".to_string(),
        modal: Some(Color::linear_rgba(0., 0., 1., 0.75).into()),
        timeout: TextPopupTimeout::Seconds(10),
        dismiss_button: Some(TextPopupButton {
            text: "Close".to_string(),
            text_color: TextColor::from(Color::BLACK),
            background_color: Color::linear_rgb(1., 1., 1.).into(),
            ..Default::default()
        }),
        name: Some(Name::new("custom_popup_name")), // Name component will be added to entity.
        ..default()
    });
}

Buttons

cargo run --example buttons

Buttons Example

Border

cargo run --example border

Border

Custom Font

cargo run --example custom_font

Custom Font Example

Locations

cargo run --example locations

Locations

And example showing custom pixel coordinates:

cargo run --example custom_locations

Modal

cargo run --example modal

Modal

Transparency

cargo run --example transparency

Transparency

Bevy Compatibility

bevy bevy_text_popup
0.15 0.5
0.14 0.4
0.13 0.3
0.12 0.2
0.11 0.1

Dependencies

~22–33MB
~528K SLoC