How can i add name bar for my sprite? #12883
-
I tried to do this, but it didn't work。 fn setup(mut commands: Commands){
commands.spawn(SpriteBundle{
transform: Transform {
translation: Vec3::new(0.0, 0.0, 0.0),
scale: Vec3 { x: 80., y: 80., z: 0. },
..default()
},
sprite: Sprite {
color: Color::BLUE,
..default()
},
..default()
}).with_children(|parent| {
parent.spawn(TextBundle::from_sections([
TextSection::new("Some".to_string(), text_style.clone()),
TextSection::new(
"Action".to_string(),
TextStyle {
color: Color::YELLOW,
..text_style.clone()
},
)
]));
});
} can`t saw any text in render? how can i fix it? |
Beta Was this translation helpful? Give feedback.
Answered by
SolarLiner
Apr 5, 2024
Replies: 1 comment 1 reply
-
Text is UI and does not follow 2D game elements (like Sprites), you need to use |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
SolarLiner
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Text is UI and does not follow 2D game elements (like Sprites), you need to use
Text2dBundle
for your use-case.