[UI] How to layout text with absolute position in 0.15
?
#17135
-
I'm trying to migrate the following code from let text_bundle = TextBundle::from_section(
get_elapsed_time_text(&simulated_time),
TextStyle {
font: asset_server.load("fonts/FiraMono-Medium.ttf"),
font_size: 40.0,
color: TEXT_COLOR,
},
)
.with_style(Style {
position_type: PositionType::Absolute,
top: PADDING,
left: PADDING,
..default()
}); In Here's my current implementation, which is slightly off-center due to the let text_bundle = (
Text2d::new(get_elapsed_time_text(&simulated_time)),
TextFont {
font: asset_server.load("fonts/FiraMono-Medium.ttf"),
font_size: 40.0,
..default()
},
TextColor(TEXT_COLOR),
Node {
position_type: PositionType::Absolute,
top: PADDING,
left: PADDING,
..default()
},
); |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
That's nearly correct, but you want the |
Beta Was this translation helpful? Give feedback.
-
That was the issue @rparrett, thank you! |
Beta Was this translation helpful? Give feedback.
That's nearly correct, but you want the
Text
component for UI, notText2d
.