Expand description
Dynamic effects are normal rust types that are
dynamically constructed at run time and inserted into text hierarchies.
Dynamic effects refer to ECS driven effects, such as shake. For shader
effects, see materials.
§Using Dynamic Effects
// Built-in effects are provided with the `default_effects` feature!
world.spawn(pretty!("`my shaky text span`[shake]"));
world.spawn(pretty!("`my wavy text span`[wave]"));
// ...
// Default arguments example
#[derive(Default)]
struct Shake {
arg1: usize,
arg2: f32,
}
world.spawn(
pretty!("`my shaky text span`[shake(10)]"),
// arg2 is defaulted! -^
);
// This is just syntax sugar for:
Shake {
arg1: 10,
..Default::default()
};§Defining Custom Effects
To position glyphs, use GlyphOrigin and
GlyphOffset. Ensure that updates to the
GlyphOffset occur in the Update
schedule before the GlyphSystems::Position
system set.
ⓘ
// Defining a custom effect.
#[derive(Default, Component, DynamicEffect)]
#[require(PrettyText)]
struct MyEffect {
field1: f32,
field2: usize,
}
// Registering `MyEffect`.
app.register_pretty_effect::<MyEffect>("my_effect");
// Using `MyEffect`.
world.spawn(pretty!("`my text span`[my_effect]"));
// Using `MyEffect` with arguments.
world.spawn(pretty!("`my text span`[my_effect(1)]"));
world.spawn(pretty!("`my text span`[my_effect(1, 1)]"));Structs§
- DynEffect
Registry - Dynamic effect registry.
- Pretty
Text Effect - A dynamic representation of a text effect.
Traits§
- Dynamic
Effect - Constructs
Selffromargsand inserts into an entity. - Pretty
Text Effect AppExt - Extension trait for registering dynamic effects.