-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
A-UIGraphical user interfaces, styles, layouts, and widgetsGraphical user interfaces, styles, layouts, and widgetsC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behavior
Description
This may be as much an issue of documentation as of code, but I'm trying to center a single character within a square node with the following code:
commands
.spawn(
NodeComponents {
style: Style {
size: Size::new(Val::Px(64.0), Val::Px(64.0)),
border: Rect::all(Val::Px(2.0)),
position_type: PositionType::Absolute,
position: Rect {
left: Val::Px(64.0),
right: Val::Px(64.0),
top: Val::Px(64.0),
bottom: Val::Px(64.0),
},
// I expect one of these to center the text in the node
align_content: AlignContent::Center,
align_items: AlignItems::Center,
align_self: AlignSelf::Center,
..Default::default()
},
material: materials.add(Color::rgb(0.4, 0.4, 0.4).into()),
..Default::default()
}
)
.with_children(|parent| {
parent
.spawn(TextComponents {
text: Text {
value: "0".to_string(),
font: font_handle,
style: TextStyle {
font_size: 64.0,
color: Color::WHITE,
}
},
// I would expect this to horizontally stretch the text within the node
transform: Transform::from_non_uniform_scale(Vec3::new(2.0, 1.0, 1.0)),
..Default::default()
});
})
;
However, what I get is just this:
The stretch transform seems to do nothing and neither do any of the align
attributes.
Cykooz
Metadata
Metadata
Assignees
Labels
A-UIGraphical user interfaces, styles, layouts, and widgetsGraphical user interfaces, styles, layouts, and widgetsC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behavior