I'm trying to align text within a parent GUI node. The pink is the child node, taking up 100% of the space of the parent node, but the text of this node remains left justified no matter what I do, regardless of the size of the node in which it exists. Changing the Text::alignment field only shifts the kerning a bit, but doesn't seem to actually move the text anywhere within the node
#bevy_ui align text within parent gui node
1 messages · Page 1 of 1 (latest)
So the hierarchy is
Parent node (covered in the screenshot) -> Child node (Pink, contains the TextBundle components)
According to flexbox.help
{
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: center;
align-items: stretch;
align-content: stretch;
}``` should do it, but instead it does nothing
Ah! I had to set the parent's style to column too
yes it's a bit confusing but the text alignment field doesn't affect the position of the text only its internal alignment
Then I actually don't understand what the text alignment field even does
I guess that doesn't matter though
if you have a text with multiple lines
then left aligned text will be lined up against the left edge, and right aligned text will lined up against the right edge
Okay but then why can't I align a child node within a parent?
within its ui node, but the node containing the text doesn't move
It can take up all the space inside the parent but it seemingly can't be aligned within that space
usually you just need to just need to set either align_items or justify_content depending on the flex direction
Look! It works now!
if you add a background_color to the text node entity it often makes it clearer whats happening
Hmm I wonder if I could shrink the parent to fit its contents
That's what the pink was
I could take up all the parent's space, but I couldn't actually move the alignment within that space, other than vertically
Hmm it seems like I can't actually both make the column grow in width to fit the contents AND make it align to the right side of the screen
Maybe with another parent node on top of that in ColumnReverse