bevyengine / bevy

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

In bevy 0.13.1 , only a single NodeBundle will work. spawning multiple UI node bundles will destroy the others ones #12624

Closed ethereumdegen closed 8 months ago

ethereumdegen commented 8 months ago

Bevy version

The release number or commit hash of the version you're using.

0.13.1

What you did

Describe how you arrived at the problem. If you can, consider providing a code snippet or link.

In bevy 0.13.1 , only a single NodeBundle will work. spawning multiple UI node bundles will destroy the others ones

What went wrong

Additional information

alice-i-cecile commented 8 months ago

Discussed in an unstructured way on Discord here, for those looking for more information / history.

ethereumdegen commented 8 months ago

the last menu that i spawn works and ONLY that one - no others one

.fn_plugin(ui_menu_state::ui_menu_state_plugin) .fn_plugin(ui_button_events::ui_button_events_plugin)

    .fn_plugin(hud_menu::hud_menu_plugin)

    .fn_plugin(game_over_menu::game_over_menu_plugin )

    .fn_plugin( main_menu::main_menu_plugin )

    .fn_plugin( character_menu::character_menu_plugin )

    .fn_plugin(select_ability_menu::select_ability_menu_plugin)

    .fn_plugin( system_menu::system_menu_plugin )
    .fn_plugin( dialog_menu::dialog_menu_plugin )

so if i spawn my dialog menu last, that is the only one that works so it seems kind of like.... NodeBundles are overwriting the previous ones and killign the previosuly spawned one s

ethereumdegen commented 8 months ago

https://gist.github.com/ethereumdegen/46c064eb932f2624e97d78abc9085115

ethereumdegen commented 8 months ago

some of my code ^^ . Pretty standard Bevy UI stuff is what is breaking. Basically only the last NodeBundle i spawn with commands.spawn() actually works.. the others dont

rparrett commented 8 months ago

If someone is able to produce an MRE based on the information here, that would be helpful.

extrawurst commented 8 months ago

i am also running into this as it seems. just updated to 0.13.1 and almost all UI disappeared

FylmTM commented 8 months ago

Encountered same bug. Seems that since 0.13.1 you can only have one root NodeBundle for UI camera (or something like this).

I am spawning UI in several separate pieces, via several nodebundles. Only first NodeBundle is displayed.

Will try to construct RME.

FylmTM commented 8 months ago

Example to reproduce: https://github.com/FylmTM/bevy_rme_ui

After creating minimal example, it seems that we have different behaviour now. Previously root nodes very sort of absolutely overlayed over each other. But now they are stacked.

Before (0.13.0 image

After (0.13.1) image

nicoburns commented 8 months ago

This might be https://github.com/bevyengine/bevy/issues/12255#issuecomment-1974961300. This is exactly the issue I was expecting from that change.

StrikeForceZero commented 8 months ago

This might be #12255 (comment). This is exactly the issue I was expecting from that change.

confirmed, reverting just my commit exhibits the 13.0 behavior.

StrikeForceZero commented 8 months ago

setting PositionType::Absolute on the root nodes seems to make it behave like it did in 13.0

image

use bevy::app::{App, PreStartup};
use bevy::prelude::*;

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

    let mut size = 150.;

    commands.spawn(NodeBundle {
        style: Style {
            position_type: PositionType::Absolute,
            width: Val::Px(size),
            height: Val::Px(size),
            ..default()
        },
        background_color: Color::RED.into(),
        ..default()
    });

    size -= 50.;

    commands.spawn(NodeBundle {
        style: Style {
            position_type: PositionType::Absolute,
            width: Val::Px(size),
            height: Val::Px(size),
            ..default()
        },
        background_color: Color::GREEN.into(),
        ..default()
    });

    size -= 50.;

    commands.spawn(NodeBundle {
        style: Style {
            position_type: PositionType::Absolute,
            width: Val::Px(size),
            height: Val::Px(size),
            ..default()
        },
        background_color: Color::BLUE.into(),
        ..default()
    });
}

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_systems(PreStartup, setup)
        .run();
}
RobertBrewitz commented 8 months ago

setting PositionType::Absolute on the root nodes seems to make it behave like it did in 13.0

Hello :wave: I can confirm this works :heavy_check_mark:

As a consumer of Bevy, it makes sense that the 13.0 behavior only occurs when a root node is positioned absolute. Aligns with how Taffy and CSS treats absolute and relative positioning.