Skip to content

Bug in TextBundle #9192

Closed
Closed
@shenjiangqiu

Description

@shenjiangqiu

Bevy version

0.11.0

Relevant system information

rust 1.71

What you did

I add a text bundle to show the fps and a counter:
in setup:

commands.spawn((
        TextBundle::from_sections([
            text_section(Color::GREEN, "\nFPS (SMA): "),
            text_section(Color::CYAN, ""),
            text_section(Color::GREEN, "\nCounter: "),
            text_section(Color::CYAN, "111"),
        ])
        .with_style(Style {
            position_type: PositionType::Absolute,
            top: Val::Px(15.0),
            left: Val::Px(15.0),
            ..default()
        }),
        FpsLabel,
    ));

in update:

let mut text = query.single_mut();

    if let Some(fps) = diagnostics.get(FrameTimeDiagnosticsPlugin::FPS) {
        if let Some(sma) = fps.average() {
            text.sections[1].value = format!("{sma:.2}");
        }
    };
    text.sections[3].value = format!("{}", ball_counter.0);

What went wrong

the line of counter not showing on the screen!
but if I add a empty line after it:

...
TextBundle::from_sections([
            text_section(Color::GREEN, "\nFPS (SMA): "),
            text_section(Color::CYAN, ""),
            text_section(Color::GREEN, "\nCounter: "),
            text_section(Color::CYAN, "111"),
            text_section(Color::CYAN, "\n END"),
        ])
...
now the Counter appears! but the END not shows on the screen
  • screenshots

  • before add text_section(Color::CYAN, "\n END"),
    截屏2023-07-18 上午12 44 06

  • after add text_section(Color::CYAN, "\n END"),
    截屏2023-07-18 上午12 48 19

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-UIGraphical user interfaces, styles, layouts, and widgetsC-BugAn unexpected or incorrect behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions