bevy
bevy copied to clipboard
Make each `TextSection` its own entity.
Objective
This change makes each TextSection
its own entity, which was discussed to be the next step for bevy_text
in Discord.
Fixes #7714
Solution
- Changed the
Text
component to hold no sections instead of aVec
ofTextSection
. - Made
TextSection
a component that should be added to children of aText
. - Adjustments to make the code compile again.
Testing
Tested out some of the examples that I ported to the new API, they all look fine.
Migration Guide
Any usage of TextBundle::from_section
or Text::from_section
should be replaced with something like this:
//old
commands.spawn(TextBundle::from_section("My Text", TextSection::default()));
// new
commands.spawn(TextBundle::default()).with_child(TextSection::from("My Text"));
Same goes for the from_sections
methods.