You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you add a Node as a child of a Text, the text is not rendered at all.
use bevy::prelude::*;fnmain(){App::new().add_plugins(DefaultPlugins).add_systems(Startup, setup).run();}fnsetup(mutcommands:Commands){
commands.spawn(Camera2d);
commands
.spawn((Text::new("hello\nbevy!"),TextFont{font_size:67.0,
..default()},Node{left:Val::Px(20.),
..default()},))// Adding this makes the above text disappear.with_child((Node{width:Val::Px(40.),height:Val::Px(40.),
..default()},BackgroundColor(Color::WHITE.with_alpha(0.5)),));}
What went wrong
I would expect the text to remain visible.
The entity with Text still seems to contribute to the layout, but it doesn't show up. It seems that Text is somehow hardcoded to only allow TextSpan children and breaks with anything else.
I ran into this while trying to make pseudo outlines by drawing multiple texts on top of each other in the hierarchy, but the parent text just doesn't show up.
The text was updated successfully, but these errors were encountered:
I think it would be convenient to sometimes have extra nodes that are positioned relative to text, e.g. a poison icon attached to a poison number.
Is there any reason this needs to work like this? Why not just display non-leaf text?
But yeah you can work around this by having another parent node for the text and add the secondary text as a sibling with absolute positioning.
It's easier to implement pseudo-outlines using an extraction system. Should be straightforward to repurpose the changes from #17559.
Thanks. I'll look into that. Extraction doesn't seem very approachable for user code but good to know. Also I'm using another font for the outline so that code won't work directly.
Bevy version
main (1c765c9)
What you did
When you add a
Node
as a child of aText
, the text is not rendered at all.What went wrong
I would expect the text to remain visible.
The entity with
Text
still seems to contribute to the layout, but it doesn't show up. It seems thatText
is somehow hardcoded to only allowTextSpan
children and breaks with anything else.I ran into this while trying to make pseudo outlines by drawing multiple texts on top of each other in the hierarchy, but the parent text just doesn't show up.
The text was updated successfully, but these errors were encountered: