Skip to main content

Crate bevy_pretty_text

Crate bevy_pretty_text 

Source
Expand description

crates.io docs.rs

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

FlagDescriptionDefault feature
serializeEnable 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 Text and Text2d entities 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 SpawnRelatedBundle that will insert the Effects component, spawn a SpawnableList of entities with given bundles that relate to the Effects entity via the EffectOf component, and reserve space in the Effects for each spawned entity.

Structs§

PrettyText
Top level text component.
PrettyTextPlugin
bevy_pretty_text’s top-level plugin.