bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
36.52k stars 3.6k forks source link

ui border is quietly ignored for entities with ContentSize #11557

Open stepancheg opened 10 months ago

stepancheg commented 10 months ago

Bevy version

main

What you did

use bevy::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_systems(Startup, hello_world_system)
        .run();
}

fn hello_world_system(mut commands: Commands) {
    commands.spawn(Camera2dBundle::default());

    commands.spawn(NodeBundle {
        style: Style {
            min_width: Val::Px(500.),
            min_height: Val::Px(500.),
            border: UiRect::all(Val::Px(20.)),
            ..Style::default()
        },
        background_color: BackgroundColor(Color::BLUE),
        border_color: BorderColor(Color::YELLOW_GREEN),
        ..NodeBundle::default()
    });

    commands.spawn((
        TextBundle {
            text: Text::from_section(
                "Hi",
                TextStyle {
                    font_size: 100.,
                    ..TextStyle::default()
                },
            ),
            style: Style {
                min_width: Val::Px(500.),
                min_height: Val::Px(500.),
                left: Val::Px(600.),
                // Here we asked for border.
                border: UiRect::all(Val::Px(5.)),
                ..Style::default()
            },
            background_color: BackgroundColor(Color::VIOLET),
            ..TextBundle::default()
        },
        BorderColor(Color::ORANGE_RED),
    ));
}

What went wrong

There's no border around text node, even if border size is specified explicitly in TextBundle.

image

What is expected

nicoburns commented 10 months ago

This is known, considered a bug, and should be fixed by #10690