bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Make each `TextSection` its own entity.

Open Olle-Lukowski opened this issue 6 months ago • 9 comments

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 a Vec of TextSection.
  • Made TextSection a component that should be added to children of a Text.
  • 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.

Olle-Lukowski avatar Aug 01 '24 15:08 Olle-Lukowski