https://github.com/mintlu8/bevy_spawn_fn
Hyper optimized spawning experience for bevy.
https://github.com/mintlu8/bevy_spawn_fn
Last synced: about 1 year ago
JSON representation
Hyper optimized spawning experience for bevy.
- Host: GitHub
- URL: https://github.com/mintlu8/bevy_spawn_fn
- Owner: mintlu8
- License: apache-2.0
- Created: 2024-06-08T09:58:47.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-30T20:02:20.000Z (almost 2 years ago)
- Last Synced: 2024-11-10T04:53:54.484Z (over 1 year ago)
- Language: Rust
- Size: 29.3 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# bevy_spawn_fn
Awesome spawning experience for bevy.
## Getting Started
Annotate your system with `#[spawner_system]`, then use the `spawn!` macro.
```rust
#[spawner_system]
pub fn particle_emitter(emitter: Res) {
if emitter.should_spawn() {
spawn! {
ParticleBundle {
color: Color::Green,
size: 10.0,
texture: @load "images/my_image.png"
}
}
}
}
```
If the function not a system, use the `#[spawner_fn]` macro,
which takes less liberty in rewriting the function.
## The `spawn!` macro
`spawn!` spawns a `IntoSpawnable` and return an `Entity`.
The macro uses the `infer_construct!` macro from
the [`default_constructor`](https://docs.rs/default-constructor) crate under the hood,
which uses the `InferInto` trait for conversion.
Additionally effect `@load` can be used to load `Handle` from
a string path and `@asset` can be used to convert `impl Into` to `Handle`
via `AssetServer`.
## The `Spawnable` Trait
`Spawnable` is a superset of `Bundle` that can be implemented to spawn
heterogenous bundles and children.
`IntoSpawnable` is free ergonomics on top of `Spawnable`!
## Versions
| bevy | bevy_spawn_fn |
|------|--------------------|
| 0.13 | latest |
## License
License under either of
Apache License, Version 2.0 (LICENSE-APACHE or )
MIT license (LICENSE-MIT or )
at your option.
## Contribution
Contributions are welcome!
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.