#bevy-ui #signal #inspector #ui #bevy #gamedev

aalo

aka bevy-inspector-haalka, a bevy_ui-native inspector for Bevy

4 releases

new 0.0.4 Apr 13, 2025
0.0.3 Apr 10, 2025
0.0.2 Apr 10, 2025
0.0.1 Apr 9, 2025
0.0.0 Aug 4, 2024

#517 in Game dev

Download history 2/week @ 2025-01-29 4/week @ 2025-02-26 545/week @ 2025-04-09

545 downloads per month

MIT/Apache

390KB
7.5K SLoC

aalo আলো

Crates.io Version Docs.rs Following released Bevy versions

in bengali, aalo means "light" (i.e. photons), not to be confused with haalka !

aalo is a bevy_ui-native inspector built with haalka which aims to port much of the behavior of bevy-inspector-egui to bevy_ui

setup

[dependencies]
aalo = { version = "0.0", optional = true }

[features]
development = ["aalo"]

HIGHLY RECOMMENDED, while not required, aalo is much snappier when compiled in release mode, you'll only need to do so once

[profile.dev.package.aalo]
opt-level = 3 
#[cfg(feature = "development")]
use aalo::prelude::*;

#[cfg(feature = "development")]
app.add_plugins(AaloPlugin::new().world());

registering custom frontends

use register_frontend, passing in a fully qualified type path and a function that returns an impl Bundle, e.g. Node, whose Entity also has a FieldListener Component; FieldListener is just a wrapper around a SystemId<In<Box<dyn PartialReflect>>>, which will be forwarded the corresponding field's value every frame it is visible in the inspector, aalo will unregister the system for you when the entity is despawned

fn init_custom_bool_frontend(mut world: DeferredWorld, entity: Entity, _: ComponentId) {
    let mut commands = world.commands();
    let text = commands.spawn_empty().id();
    let system = commands.register_system(
        move |In(reflect): In<Box<dyn PartialReflect>>, mut commands: Commands| {
            let cur_option = reflect.try_downcast_ref::<bool>().copied().or_else(|| {
                CustomBoolComponent::from_reflect(reflect.as_ref())
                    .map(|CustomBoolComponent(cur)| cur)
            });
            if let Some(cur) = cur_option {
                commands.entity(text).insert(Text(cur.to_string()));
            }
        },
    );
    commands
        .entity(entity)
        .add_child(text)
        .insert(FieldListener::new(system))
        .observe(
            move |click: Trigger<Pointer<Click>>, texts: Query<&Text>, mut field: TargetField| {
                if let Ok(Text(text)) = texts.get(text) {
                    let cur = match text.as_str() {
                        "true" => true,
                        "false" => false,
                        _ => return,
                    };
                    // one of these will silently error depending on if it's the field or component
                    // target, we just do both here for the convenience of using the same frontend
                    field.update(click.entity(), (!cur).clone_value());
                    field.update(click.entity(), CustomBoolComponent(!cur).clone_value());
                }
            },
        );
}

#[derive(Component)]
#[require(Node)]
#[component(on_add = init_custom_bool_frontend)]
struct CustomBoolFrontend;

fn custom_bool_frontend() -> impl Bundle {
    CustomBoolFrontend
}

#[derive(Component, Reflect, Default)]
struct CustomBoolComponent(bool);

register_frontend("bool", custom_bool_frontend);
register_frontend("custom::CustomBoolComponent", custom_bool_frontend);

see custom frontend example

hotkeys

/: open search

:: open targeting

tab/shift-tab: iterate up/down through search/targeting parts

left arrow/right arrow: iterate left/right through search/targeting roots

esc: close search/targeting

examples

on the web

All examples are compiled to wasm for both webgl2 and webgpu (check compatibility) and deployed to github pages.

Bevy compatibility

bevy aalo
0.15 0.0

license

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

at your option.

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

~59–94MB
~1.5M SLoC