Reflect TextLayout and ComputedTextBlock (#16296)

# Objective

- Fix panic when saving/loading scenes with text nodes due to missing
Reflect implementations.
This commit is contained in:
s-puig 2024-11-08 23:36:31 +01:00 committed by GitHub
parent 56a002b693
commit 5cbc2a9018
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View file

@ -116,6 +116,8 @@ impl Plugin for TextPlugin {
.register_type::<TextColor>()
.register_type::<TextSpan>()
.register_type::<TextBounds>()
.register_type::<TextLayout>()
.register_type::<ComputedTextBlock>()
.init_asset_loader::<FontLoader>()
.init_resource::<FontAtlasSets>()
.init_resource::<TextPipeline>()

View file

@ -28,7 +28,8 @@ impl Default for CosmicBuffer {
/// A sub-entity of a [`ComputedTextBlock`].
///
/// Returned by [`ComputedTextBlock::entities`].
#[derive(Debug, Copy, Clone)]
#[derive(Debug, Copy, Clone, Reflect)]
#[reflect(Debug)]
pub struct TextEntity {
/// The entity.
pub entity: Entity,
@ -41,7 +42,8 @@ pub struct TextEntity {
/// See [`TextLayout`].
///
/// Automatically updated by 2d and UI text systems.
#[derive(Component, Debug, Clone)]
#[derive(Component, Debug, Clone, Reflect)]
#[reflect(Component, Debug, Default)]
pub struct ComputedTextBlock {
/// Buffer for managing text layout and creating [`TextLayoutInfo`].
///
@ -49,6 +51,7 @@ pub struct ComputedTextBlock {
/// `TextLayoutInfo`. If you want to control the buffer contents manually or use the `cosmic-text`
/// editor, then you need to not use `TextLayout` and instead manually implement the conversion to
/// `TextLayoutInfo`.
#[reflect(ignore)]
pub(crate) buffer: CosmicBuffer,
/// Entities for all text spans in the block, including the root-level text.
///