Skip to content

max_size not working on NodeBundle #8072

Closed
@tecbeast42

Description

@tecbeast42

Bevy version

v0.10

What you did

I added 2 NodeBundles. The parent is blue, the child is red. The child should have a max size of 600 px.

use bevy::prelude::*;

fn main() {
    let mut app = App::new();
    app.add_plugins(
        DefaultPlugins
    );
    app.add_startup_system(setup);
    app.run();
}

fn setup(
    mut commands: Commands,
) {
    commands.spawn(Camera2dBundle::default());
    commands.spawn(NodeBundle {
        style: Style {
            size: Size::new(Val::Auto, Val::Percent(100.0)),
            ..default()
        },
        background_color: Color::BLUE.into(),
        ..default()
    }).with_children(|damage_report| {
            damage_report.spawn((
                NodeBundle {
                    style: Style {
                        margin: UiRect::all(Val::Px(5.0)),
                        padding: UiRect::all(Val::Px(5.0)),
                        size: Size::new(Val::Px(450.0), Val::Undefined),
                        max_size: Size::new(Val::Undefined, Val::Px(600.0)),
                        flex_direction: FlexDirection::Column,
                        justify_content: JustifyContent::SpaceEvenly,
                        align_items: AlignItems::FlexStart,
                        ..default()
                    },
                    background_color: Color::RED.into(),
                    ..default()
                },
            ));
        });
}

What went wrong

The red child node fills the full parent node, even though the max_size is limited to 600 px.

Additional information

image

image

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