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

Child TextBundle render in bottom left corner if parent is Display::None #1135

Closed
aspin opened this issue Dec 23, 2020 · 5 comments
Closed
Labels
A-Hierarchy Parent-child entity hierarchies A-UI Graphical user interfaces, styles, layouts, and widgets C-Bug An unexpected or incorrect behavior

Comments

@aspin
Copy link

aspin commented Dec 23, 2020

Bevy version

Checked on both 0.4 and 61ce3f7.

Operating system & version

macOS Catalina

What you did

Added a child TextBundle to a root NodeBundle, then set the root node to not be displayed.

Here's a full script:

use bevy::prelude::*;

fn main() {
    App::build()
        .add_plugins(DefaultPlugins)
        .add_startup_system(setup.system())
        .run();
}

fn setup(
    commands: &mut Commands,
    asset_server: Res<AssetServer>,
    mut materials: ResMut<Assets<ColorMaterial>>,
) {
    commands
        // ui camera
        .spawn(CameraUiBundle::default())
        // root node
        .spawn(NodeBundle {
            style: Style {
                size: Size::new(Val::Percent(100.0), Val::Percent(100.0)),
                justify_content: JustifyContent::SpaceBetween,
                display: Display::None,
                ..Default::default()
            },
            material: materials.add(Color::NONE.into()),
            ..Default::default()
        })
        .with_children(|parent| {
            parent.spawn(TextBundle {
                style: Style {
                    position_type: PositionType::Absolute,
                    position: Rect {
                        bottom: Val::Px(0.),
                        right: Val::Px(0.),
                        ..Default::default()
                    },
                    ..Default::default()
                },
                text: Text {
                    value: "SAMPLE TEXT".to_string(),
                    font: asset_server.load("fonts/FiraSans-Bold.ttf"),
                    style: TextStyle {
                        color: Color::WHITE,
                        font_size: 30.0,
                        ..Default::default()
                    },
                    ..Default::default()
                },
                ..Default::default()
            });
        });
}

What you expected to happen

TextBundle should not have been shown on the screen at all.

What actually happened

TextBundle rendered to the bottom left corner of the screen.

Additional information
Unexpected:
unexpected result

If root is displayed:
if root is hown

@Moxinilian Moxinilian added C-Bug An unexpected or incorrect behavior A-UI Graphical user interfaces, styles, layouts, and widgets labels Dec 23, 2020
@kumorig
Copy link

kumorig commented Dec 25, 2020

#838 (May or may not be related)

@aspin
Copy link
Author

aspin commented Dec 25, 2020

I believe that this is a regression from 0.3. Display::None worked to hide child elements in 0.3 (I think you pointed that out to me in discord), while is_visible didnt.

@ristew
Copy link

ristew commented Apr 19, 2021

I'm still having this issue, interesting is the computed node size is still zero so I can use this as a workaround:

fn issue_1135_system(
    mut text_style_visible_query: Query<(&Text, &Node, &mut Visible)>,
) {
    for (text, node, mut visible) in text_style_visible_query.iter_mut() {
        if node.size == Vec2::ZERO {
            visible.is_visible = false;
        } else {
            visible.is_visible = true;
        }
    }
}

@swwind
Copy link

swwind commented Jul 14, 2021

Problem still exists in 0.5.0.

@alice-i-cecile alice-i-cecile added the A-Hierarchy Parent-child entity hierarchies label Apr 4, 2022
@rparrett
Copy link
Contributor

This was fixed by #3312.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Hierarchy Parent-child entity hierarchies 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

7 participants