bevy_mod_ui_sprite

Crates.iobevy_mod_ui_sprite
lib.rsbevy_mod_ui_sprite
version0.2.1
sourcesrc
created_at2022-10-11 16:42:22.112661
updated_at2022-10-12 14:17:48.017302
descriptionDraw sprites with the Bevy UI
homepage
repositoryhttps://github.com/ickshonpe/bevy_mod_ui_sprite
max_upload_size
id685429
size105,843
(ickshonpe)

documentation

README

bevy_mod_ui_sprite

crates.io MIT/Apache 2.0 crates.io

Draw sprites, texture atlas sprites, and colored rectangles with the Bevy UI.

image

Usage

Add the dependency to Cargo.toml:

bevy_mod_ui_sprite = "0.2.1"

Add the plugin to your app:

use bevy_mod_ui_sprite::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugin(UiSpritePlugin)
        // ..rest of app
        .run()
}

Don't forget a camera:

commands.spawn_bundle(Camera2dBundle::default());

Then you can spawn a UiSpriteBundle:

commands.spawn_bundle(UiSpriteBundle {
    sprite: UiSprite::Image(asset_loader.load("sprite.png")),
    size: SpriteSize::Size(Vec2::new(64., 64.)),
    color: UiColor(Color::YELLOW),
    transform: Transform::from_translation(Vec3::new(100., 100., 100.)),
    ..Default::default()
});

Full Example

cargo --run --example example

Notes

Performance should be fine, but this crate is not a substitute for the much more efficient Bevy 2D renderer.

Commit count: 12

cargo fmt