https://github.com/djeedai/bevy_bootloader
App startup and resource management plugin for the Bevy game engine.
https://github.com/djeedai/bevy_bootloader
bevy bevy-plugin boot resource-management rust utility
Last synced: 2 months ago
JSON representation
App startup and resource management plugin for the Bevy game engine.
- Host: GitHub
- URL: https://github.com/djeedai/bevy_bootloader
- Owner: djeedai
- License: other
- Created: 2022-03-22T20:59:00.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-03-22T20:59:19.000Z (over 4 years ago)
- Last Synced: 2025-04-05T00:41:42.135Z (about 1 year ago)
- Topics: bevy, bevy-plugin, boot, resource-management, rust, utility
- Language: Rust
- Homepage:
- Size: 17.6 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# 🚥 Bevy Bootloader
[](https://opensource.org/licenses/MIT)
[](https://docs.rs/bevy_bootloader)
[](https://crates.io/crates/bevy_bootloader)
[](https://github.com/djeedai/bevy_bootloader/actions/workflows/ci.yaml)
[](https://coveralls.io/github/djeedai/bevy_bootloader?branch=main)
[](https://github.com/bevyengine/bevy/blob/main/docs/plugins_guidelines.md#main-branch-tracking)
App startup and resource management plugin for the Bevy game engine.
## Usage
### Dependency
Add to `Cargo.toml`:
```toml
[dependencies]
bevy_bootloader = "0.1"
```
### System setup
Add the `BootloaderPlugin` to your app:
```rust
App::default()
.add_plugins(DefaultPlugins)
.add_plugin(BootloaderPlugin)
.run();
```
Queue boot-time critical assets, and insert a `BootBundle`:
```rust
// Queue boot-time resources
let mut loader = Loader::new();
loader.enqueue("logo.png");
loader.enqueue("music.ogg");
loader.submit();
// Insert a boot bundle
commands.spawn_bundle(BootBundle::new(loader));
```
Check the boot state with either of `Boot::progress()`, `Boot::smoothed_progress()`, or
`Loader::is_done()`. For example, use `Boot::smoothed_progress()` to smoothly update a
progress bar made of a `Sprite`:
```rust
fn update_progress_bar(
boot_query: Query<&Boot>,
mut sprite_query: Query<(&mut Transform, &mut Sprite), With>,
) {
if let Ok(boot) = boot_query.get_single() {
// Update the progress bar based on the fraction of assets already loaded, smoothed
// with a snappy animation to be visually pleasant without too much artifically
// delaying the boot sequence.
let smoothed_progress = boot.smoothed_progress();
let (mut transform, mut sprite) = sprite_query.single_mut();
let size = PROGRESS_BAR_SIZE * smoothed_progress;
// The sprite is a rect centered at the transform position, so move by half size to
// keep aligned to the left while width grows.
transform.translation.x = (size - PROGRESS_BAR_SIZE) / 2.;
sprite.custom_size = Some(Vec2::new(size, PROGRESS_BAR_THICKNESS));
}
}
```
See [the `bootloader` example](./examples/bootloader.rs) for the full code.
## Compatible Bevy versions
The `main` branch is compatible with the latest Bevy release.
Compatibility of `bevy_bootloader` versions:
| `bevy_bootloader` | `bevy` |
| :-- | :-- |
| `0.1` | `0.6` |
Due to the fast-moving nature of Bevy and frequent breaking changes, and the limited resources to maintan 🚥 Bevy Bootloader, the `main` (unreleased) Bevy branch is not supported.