Add some multi-span text to the text2d example (#17308)

# Objective

The `Text2d` example should have have some multi-span text.

Co-authored-by: François Mockers <mockersf@gmail.com>
This commit is contained in:
ickshonpe 2025-01-14 07:58:21 +00:00 committed by GitHub
parent b0beeab41a
commit d34803f5f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -125,13 +125,23 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
(Anchor::BottomRight, Color::Srgba(BLUE)), (Anchor::BottomRight, Color::Srgba(BLUE)),
(Anchor::BottomLeft, Color::Srgba(YELLOW)), (Anchor::BottomLeft, Color::Srgba(YELLOW)),
] { ] {
commands.spawn(( commands
Text2d::new(format!(" Anchor::{text_anchor:?} ")), .spawn((
slightly_smaller_text_font.clone(), Text2d::new(" Anchor".to_string()),
TextColor(color), slightly_smaller_text_font.clone(),
Transform::from_translation(250. * Vec3::Y), Transform::from_translation(250. * Vec3::Y),
text_anchor, text_anchor,
)); ))
.with_child((
TextSpan("::".to_string()),
slightly_smaller_text_font.clone(),
TextColor(LIGHT_GREY.into()),
))
.with_child((
TextSpan(format!("{text_anchor:?} ")),
slightly_smaller_text_font.clone(),
TextColor(color),
));
} }
} }