Crates.io | bevy_mod_ui_texture_atlas_image |
lib.rs | bevy_mod_ui_texture_atlas_image |
version | 0.4.1 |
source | src |
created_at | 2022-09-30 11:12:35.164738 |
updated_at | 2023-04-06 08:32:10.378823 |
description | Draw images from texture atlases with the Bevy UI |
homepage | |
repository | https://github.com/ickshonpe/bevy_mod_ui_texture_atlas_image |
max_upload_size | |
id | 677239 |
size | 114,211 |
Draw images from texture atlases with the Bevy UI.
To use this crate, add its dependency to your project's Cargo.toml
:
bevy_mod_ui_texture_atlas_image = "0.3"
or with Cargo:
cargo add bevy_mod_ui_texture_atlas_image
UiAtlasImage
The texture atlas image of the node.
ImageTint
The tint color of the image.
AtlasImageBundle
The bundle of components needed to display an image from a TextureAtlas
with the Bevy UI.
The UiAtlasImagePlugin
plugin must be added to your Bevy App:
use bevy_mod_ui_texture_atlas_image::*;
fn main () {
App::new()
.add_plugins(DefaultPlugins)
.add_plugin(UiAtlasImagePlugin)
// ..rest of app
.run()
}
Then you can spawn an AtlasImageBundle
to draw images from a TextureAtlas
with the Bevy UI:
commands
.spawn(AtlasImageBundle {
atlas_image: UiAtlasImage {
atlas: texture_atlas_handle.clone(),
index: 5
},
..Default::default()
});
The differences between an AtlasImageBundle
and an ImageBundle
are that
UiImage
component, AtlasImageBundle
has a UiAtlasImage
component that sets the image displayed by the node.BackgroundColor
component, AtlasImageBundle
has an ImageTint
component that sets the color tint of the image.cargo --run --example minimal
cargo --run --example tiles
cargo --run --example alpha
cargo --run --example clipped