Insert UI element into existing component #6521
-
I'm working on a small video game and I encountered the following issue: I cannot find a way to insert a child into an existing element. I get the characters: &mut Query<(Entity, &mut Character, &Children)>, and then use it like this (entity is commands.entity(receiver_id) // I suppose the `receiver_id` is wrong here
.add_children(|children| {
children.spawn_bundle(TextBundle::from_section(
damage.to_string().as_str(),
TextStyle {
font: asset_server.load("fonts/kreon-regular.ttf"),
font_size: 10.0 / crate::SCALE,
color: Color::RED,
},
))
.insert(Notification {
timer: Timer::from_seconds(NOTIFICATION_TIME, false),
})
.insert_bundle(TransformBundle::from(Transform::from_xyz(
0.,
receiver.height / 2. + 2.,
0.,
)));
}); I suppose I'm doing something wrong because then it's not displayed and I get a lot of warnings:
However I checked and Any idea how I can fix this issue? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
TextBundle can only be used in ui. You probably want a Text2dBundle instead https://docs.rs/bevy/latest/bevy/text/struct.Text2dBundle.html |
Beta Was this translation helpful? Give feedback.
TextBundle can only be used in ui. You probably want a Text2dBundle instead https://docs.rs/bevy/latest/bevy/text/struct.Text2dBundle.html