Expand description
Pretty Text is a text effects library for Bevy.
§Getting Started
First, add bevy_pretty_text to the dependencies in your Cargo.toml:
[dependencies]
bevy_pretty_text = "0.4"Then, you’ll need to add the PrettyTextPlugin to your app.
use bevy::prelude::*;
use bevy_pretty_text::prelude::*;
fn main() {
App::default()
.add_plugins((DefaultPlugins, PrettyTextPlugin))
.run();
}And then you can make some pretty text!
fn spawn_text(mut commands: Commands) {
// Spawn wavy `Text`.
commands.spawn((
Text::new("Hello, World!"),
Wave::default(),
));
// Use the typewriter.
commands.spawn((
Typewriter::new(30.),
Text2d::new("My text is revealed\none glyph at a time"),
Transform::from_xyz(0., 200., 0.),
));
// Spawn a style entity.
commands.spawn((
PrettyStyle("my_style"),
TextColor(Color::WHITE),
effects![
Shake::default(),
Wave::default(),
],
));
// Parse rich text and use custom style.
commands.spawn((
pretty!("I am |1|<0.8>*sniff*|1|<1.2> very [pretty](my_style)!|3|<1>"),
Transform::from_xyz(0.0, -200.0, 0.0),
));
}The repository examples should help you get up to speed on common usage patterns.
§Table of contents
§Creating Pretty Text
§Type Writer
§Parsing
§Effects
§Style
§Feature flags
| Flag | Description | Default feature |
|---|---|---|
serialize | Enable serialization for ParsedPrettyText. | ❌ |
Modules§
- effects
- Provides built-in text effects and APIs for writing custom effects.
- glyph
- Runs systems for glyph generation and positioning.
- parser
- Provides a simple abstraction for building styled text hierarchies.
- prelude
- All
bevy_pretty_text’s important types and traits. - render
- Custom render pipelines for extracting, preparing, and queuing
TextandText2dentities for rendering. - style
- Provides a powerful API for styling text.
- typewriter
- Provides the beloved type writer text effect with additional sequencing including:
Macros§
- effects
- Returns a
SpawnRelatedBundlethat will insert theEffectscomponent, spawn aSpawnableListof entities with given bundles that relate to theEffectsentity via theEffectOfcomponent, and reserve space in theEffectsfor each spawned entity.
Structs§
- Pretty
Text - Top level text component.
- Pretty
Text Plugin bevy_pretty_text’s top-level plugin.