#ecs #bevy-ecs #bevy

bevy_spawn_observer

Add observers to your bundles

4 releases

Uses new Rust 2024

0.2.0 Oct 1, 2025
0.1.1 Aug 13, 2025
0.1.0 Apr 25, 2025
0.1.0-rc.1 Apr 23, 2025

#1684 in Game dev

MIT/Apache

35KB

bevy_spawn_observer

Crates.io Docs License

[!WARNING] This crate will stop being maintained after a final update to Bevy 0.18 in the future.

You can already use the experimental bevy::ui_widgets::observe in 0.17, and a proper upstream solution is planned for 0.18.

This crate provides SpawnObserver, a custom SpawnableList enabling you to add observers to your bundles.

use bevy::{ecs::spawn::SpawnWith, prelude::*};
use bevy_spawn_observer::SpawnObserver;

// With `bevy_spawn_observer`:
fn button_new() -> impl Bundle {
    (
        Button,
        Children::spawn(SpawnObserver::new(|_: Trigger<Pointer<Click>>| {
            info!("You clicked me!");
        })),
    )
}

// Without `bevy_spawn_observer`:
fn button_old() -> impl Bundle {
    (
        Node::default(),
        Children::spawn(SpawnWith(|parent: &mut ChildSpawner| {
            parent.spawn(Button).observe(|_: Trigger<Pointer<Click>>| {
                info!("You clicked me!");
            });
        })),
    )
}

See a full example here.

Bevy version compatibility

bevy version bevy_spawn_observer version
0.17 0.2
0.16 0.1

License

This crate is available under either of MIT or Apache-2.0 at your choice.

Dependencies

~12MB
~216K SLoC