| Crates.io | bevy_spawnable |
| lib.rs | bevy_spawnable |
| version | 0.4.1 |
| created_at | 2024-04-21 05:16:28.408869+00 |
| updated_at | 2025-08-14 13:45:49.798761+00 |
| description | tiny spawn utility for Bevy, to encapsulate spawn logic |
| homepage | |
| repository | https://github.com/funatsufumiya/bevy_spawnable |
| max_upload_size | |
| id | 1215147 |
| size | 131,753 |
A tiny spawn utility for bevy. This crate will helps you:
Commands or ChildBuilder.You can use this crate as a kind of like Unity's prefab as a code object, or builder to create entities which have complex structure.
( If you need more detailed spawn utility, consider moonshine_spawn as an alternative. )
see examples
use bevy::{ecs::system::EntityCommands, prelude::*};
use bevy_spawnable::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.run();
}
pub struct Hello {
pub text: String
}
impl Spawnable for Hello {
fn spawn<'a>(&mut self, builder: &'a mut impl GenericBuilder) -> EntityCommands<'a> {
let mut e = builder.spawn(Node {
width: Val::Percent(100.),
height: Val::Percent(100.),
flex_direction: FlexDirection::Column,
justify_content: JustifyContent::Center,
align_items: AlignItems::Center,
..default()
});
e.with_children(|root| {
root.spawn((
Text::new(self.text.clone()),
TextFont {
font_size: 50.0,
..default()
},
TextColor (
Color::WHITE.into()
),
TextLayout::new_with_justify(JustifyText::Center)
));
});
e
}}
fn setup(mut commands: Commands) {
commands.spawn(Camera2d::default());
commands.spawns(&mut Hello {
text: "Hello, Bevy!".to_string()
});
}
| bevy | bevy_spawnable |
|---|---|
| 0.16 | 0.4 |
| 0.15 | 0.3 |
| 0.14 | 0.2 |
| 0.13 | 0.1 |
Dual licensed under WTFPL and/or 0BSD.