bevy_mod_ui_independent_text

Crates.iobevy_mod_ui_independent_text
lib.rsbevy_mod_ui_independent_text
version0.3.0
sourcesrc
created_at2022-10-21 09:11:24.468488
updated_at2022-10-21 09:11:24.468488
descriptionBevy UI text with a transform independent of the UI's layout.
homepage
repositoryhttps://github.com/ickshonpe/bevy_mod_ui_independent_text
max_upload_size
id693321
size167,355
(ickshonpe)

documentation

README

bevy_mod_ui_independent_text

crates.io MIT/Apache 2.0 crates.io

Bevy UI text with a transform independent of the UI's layout.

  • Draw text at any Z depth, above or below Bevy UI elements
  • Text can be rotated and scaled
  • Customisable alignment and bounds
  • Supports Bevy 0.8

image

Usage

Add the dependency to Cargo.toml:

bevy_mod_ui_independent_text = "0.3.0"

Add the plugin to your Bevy app:

use bevy_mod_ui_independent_text::*;

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

Don't forget a camera:

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

Then you can draw text by spawning a IndependentTextBundle:

 commands.spawn_bundle(IndependentTextBundle {
        text: UiText(Text {
            sections: vec![TextSection {
                value: "Hello, world".to_string(), 
                style: TextStyle {
                    font: asset_loader.load("Topaz-8.ttf"),
                    font_size: 32.0,
                    color: Color::WHITE
                },
            }],
            alignment: TextAlignment::CENTER,
        }),
        transform: Transform {
            translation: Vec3::new(400., 300., 100.),
            rotation: Quat::from_rotation_z(std::f32::consts::PI / 8.),
            ..Default::default()
        },
       ..Default::default()
    });

image

Examples

cargo --run --example hello_world
cargo --run --example depth
cargo --run --example bounded
Commit count: 14

cargo fmt