UI/text Example - Clarity Improvements (#16302)
# Objective - Fixes #16292 ## Solution - Renames the `ColorText` marker to `AnimatedText`, which is more distinct from the `TextColor` Bevy component. - Changes the comment language from `A unit struct` to `Marker struct` for better consistency with other Bevy docs. ## Testing - Locally, example still runs just fine
This commit is contained in:
parent
1e3ecbefdb
commit
fb607b1bd1
@ -17,13 +17,13 @@ fn main() {
|
|||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
// A unit struct to help identify the FPS UI component, since there may be many Text components
|
// Marker struct to help identify the FPS UI component, since there may be many Text components
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
struct FpsText;
|
struct FpsText;
|
||||||
|
|
||||||
// A unit struct to help identify the color-changing Text component
|
// Marker struct to help identify the color-changing Text component
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
struct ColorText;
|
struct AnimatedText;
|
||||||
|
|
||||||
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
// UI camera
|
// UI camera
|
||||||
@ -47,7 +47,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
|||||||
right: Val::Px(5.0),
|
right: Val::Px(5.0),
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
ColorText,
|
AnimatedText,
|
||||||
));
|
));
|
||||||
|
|
||||||
// Text with multiple sections
|
// Text with multiple sections
|
||||||
@ -116,7 +116,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn text_color_system(time: Res<Time>, mut query: Query<&mut TextColor, With<ColorText>>) {
|
fn text_color_system(time: Res<Time>, mut query: Query<&mut TextColor, With<AnimatedText>>) {
|
||||||
for mut text_color in &mut query {
|
for mut text_color in &mut query {
|
||||||
let seconds = time.elapsed_secs();
|
let seconds = time.elapsed_secs();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user