Draw images from texture atlases with the Bevy UI.
Supports Bevy 0.8 #
Add the dependency to your project's Cargo.toml:
toml
bevy_mod_ui_texture_atlas_image = "0.1"
Then add the UiAtlasImagePlugin
plugin to your Bevy App:
```rust use bevymoduitextureatlas_image::*;
fn main () { App::new() .addplugins(DefaultPlugins) .addplugin(UiAtlasImagePlugin) // ..rest of app .run() } ```
Now you can spawn an AtlasImageBundle
to draw images from a TextureAtlas
with the Bevy UI.
rust
commands
.spawn_bundle(AtlasImageBundle {
atlas_image: UiAtlasImage {
atlas: texture_atlas_handle.clone(),
index: 5
},
..Default::default()
});
The only difference between an AtlasImageBundle
and an ImageBundle
is that instead of an image
field with type UiImage
, it has an atlas_image
field with type UiAtlasImage
.
#
cargo --run --example minimal
cargo --run --example tiles