You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I first tested this, I expected hiding a parent entity to also hide its children. This would be a useful behavior: an example would be making a rudimentary state system by having each state be represented by a root entity, and hiding the root entity of inactive states so the entire states aren't visible.
Below is a minimal example of a child still being visible after the parent is hidden, using bevy 0.3.0.
use bevy::prelude::*;fnmain(){App::build().add_plugins(DefaultPlugins).add_startup_system(setup.system()).run();}fnsetup(mutcommands:Commands,mutmaterials:ResMut<Assets<ColorMaterial>>,){
commands
.spawn(Camera2dComponents::default()).spawn(()).with(Draw{is_visible:false,
..Default::default()}).with_children(|parent| {
parent.spawn(SpriteComponents{material: materials.add(Color::BLUE.into()),sprite:Sprite::new(Vec2::new(50.0,50.0)),
..Default::default()});});}
Reacted by memoryruins, razaamir, Lavender, Anthony A Russo, Jonathan Tran, Nico, Lucas Tabis and lolgeny
Activity
razaamir commentedon Nov 11, 2020
cart commentedon Nov 12, 2020
Totally agreed. Hiding a parent should hide all descendants
kumorig commentedon Nov 22, 2020
Similar is true for Ui components using structure:
Setting the
NodeBundle.displaytoDisplay::Nonehides the button, but the text is still rendered, but in the wrong position.Tested using current latest: 1e9a054
Example with NodeBundle using Display::None
Display::Flex
Display::None
(I just assume it's the same issue) Especially since the button disappears, you would also assume the button text (or bundle?) to be hidden.
rparrett commentedon Feb 2, 2021
This workaround seems to be working for me. Posting here in case it's useful to anyone else.
Visibilty Inheritance, universal ComputedVisibility and RenderLayers …
Visibilty Inheritance, universal ComputedVisibility and RenderLayers …
Visibilty Inheritance, universal ComputedVisibility and RenderLayers …
Visibilty Inheritance, universal ComputedVisibility and RenderLayers …