#bevy-ui #bevy #tree #bundles #game-engine #enums #bundletree

bevy_bundletree

Spawn trees of bundles in the Bevy game engine

3 releases

0.1.2 Jul 15, 2024
0.1.1 May 18, 2024
0.1.0 May 18, 2024

#1557 in Game dev

MIT/Apache

480KB
97 lines

bevy_bundletree

License Crates.io Docs

Spawn trees of bundles in Bevy to make UI Code more ergonomic.

Usage

Define an enum to represent all possible bundles in your tree and derive IntoBundleTree and BundleEnum.

use bevy::prelude::*;
use bevy_bundletree::*;

#[derive(IntoBundleTree, BundleEnum)]
enum UiNode {
    Node(NodeBundle),
    Text(TextBundle),
    Button(ButtonBundle),
}
fn setup(mut commands: Commands) {
    let tree: BundleTree<UiNode> = NodeBundle::default().with_children([
        TextBundle::default().into_tree(),
        ButtonBundle::default().into_tree()]);
    commands.spawn_tree(tree);
}

Dependencies

~25MB
~462K SLoC