#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

#1342 in Game dev

Download history 4/week @ 2024-07-01 139/week @ 2024-07-15 1/week @ 2024-07-29

219 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

~23MB
~425K SLoC