Crates.io | bevy_bundletree |
lib.rs | bevy_bundletree |
version | 0.1.2 |
source | src |
created_at | 2024-05-18 22:34:17.560031 |
updated_at | 2024-07-15 01:36:59.746251 |
description | Spawn trees of bundles in the Bevy game engine. |
homepage | https://github.com/Katsutoshii/bevy_bundletree |
repository | https://github.com/Katsutoshii/bevy_bundletree |
max_upload_size | |
id | 1244532 |
size | 604,421 |
bevy_bundletree
Spawn trees of bundles in Bevy to make UI Code more ergonomic.
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);
}