// root
Node {
width: percent(100),
height: percent(100),
align_items: AlignItems::Center,
justify_content: JustifyContent::Center,
flex_direction: FlexDirection::Column,
..default()
},
children![(
// child 1
TextButton1,
Node {
position_type: PositionType::Absolute,
top: px(8),
left: px(8),
width: px(210),
height: px(30),
..default()
},
BackgroundColor(ORANGE.into()),
children![(
// child 2
Node {
align_items: AlignItems::Center,
justify_self: JustifySelf::Center,
align_self: AlignSelf::Center,
position_type: PositionType::Absolute,
..default()
},
TextFont {
font_size: 25.0,
..default()
},
Text::new("Button A"),
TextColor(BLACK.into()),
)]
),],
));``` i would like to center the text in the child 2 bundle to the center of the child 1 Node how do we do that ?
#Align center a child Node to the parent Node
7 messages · Page 1 of 1 (latest)
try adding align_content and justify_content to child 1 instead
also, when dealing with UI it is always good to have https://docs.rs/bevy/latest/bevy/prelude/struct.UiDebugOptions.html enabled
Configuration for the UI debug overlay
thanks , setting child2 to Node{..default} did the trick and align_items: AlignItems::Center, justify_self: JustifySelf::Center, to nod 1
align_contents, align_items and align_self all have different meanings, i don't know them properly, so it is always a question of attempting all permutations, same thing for the 3 justify_ ones
enabled: true,
line_width: 1.0,
line_color_override: None,
show_hidden: true,
show_clipped: true,
})``` is this how we configure the overlay ?
i usually just set the enabled: true and the rest can be ..Default::default()