#bevy #tree #bundles #enums #command #bundletree #bundle-enum

bevy_bundletree

Spawn trees of bundles in the Bevy game engine

2 releases

0.1.1 May 18, 2024
0.1.0 May 18, 2024

#469 in Game dev

Download history 270/week @ 2024-05-18 6/week @ 2024-05-25

276 downloads per month

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

~18–45MB
~699K SLoC