Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ickshonpe/bevy_mod_ui_independent_text
Bevy UI text with a transform independent of the UI's layout.
https://github.com/ickshonpe/bevy_mod_ui_independent_text
bevy bevy-engine bevy-plugin bevy-ui rust text ui
Last synced: 2 months ago
JSON representation
Bevy UI text with a transform independent of the UI's layout.
- Host: GitHub
- URL: https://github.com/ickshonpe/bevy_mod_ui_independent_text
- Owner: ickshonpe
- License: mit
- Created: 2022-10-13T12:23:45.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-10-21T09:08:21.000Z (about 2 years ago)
- Last Synced: 2024-10-01T14:36:15.114Z (3 months ago)
- Topics: bevy, bevy-engine, bevy-plugin, bevy-ui, rust, text, ui
- Language: Rust
- Homepage:
- Size: 56.6 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bevy_mod_ui_independent_text
[![crates.io](https://img.shields.io/crates/v/bevy_mod_ui_independent_text)](https://crates.io/crates/bevy_mod_ui_independent_text)
[![MIT/Apache 2.0](https://img.shields.io/badge/license-MIT%2FApache-blue.svg)](https://github.com/ickshonpe/bevy_mod_ui_independent_text)
[![crates.io](https://img.shields.io/crates/d/bevy_mod_ui_independent_text)](https://crates.io/crates/bevy_mod_ui_independent_text)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](text_depth_example.png)
## Usage
Add the dependency to `Cargo.toml`:
```toml
bevy_mod_ui_independent_text = "0.3.0"
```Add the plugin to your Bevy app:
```rust
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:
```rust
commands.spawn_bundle(Camera2dBundle::default());
```Then you can draw text by spawning a IndependentTextBundle:
```rust
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](hello_world.png)
## Examples
```
cargo --run --example hello_world
cargo --run --example depth
cargo --run --example bounded
```