Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in TextBundle #9192

Closed
shenjiangqiu opened this issue Jul 18, 2023 · 2 comments
Closed

Bug in TextBundle #9192

shenjiangqiu opened this issue Jul 18, 2023 · 2 comments
Labels
A-UI Graphical user interfaces, styles, layouts, and widgets C-Bug An unexpected or incorrect behavior

Comments

@shenjiangqiu
Copy link

shenjiangqiu commented Jul 18, 2023

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

@shenjiangqiu shenjiangqiu added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Jul 18, 2023
@nicopap
Copy link
Contributor

nicopap commented Jul 18, 2023

This should be fixed by #9133

Can you reproduce on bevy's main branch?

@nicopap nicopap added A-UI Graphical user interfaces, styles, layouts, and widgets and removed S-Needs-Triage This issue needs to be labelled labels Jul 18, 2023
@shenjiangqiu
Copy link
Author

The main branch fixed my problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-UI Graphical user interfaces, styles, layouts, and widgets C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

No branches or pull requests

2 participants