Skip to content

Hiding parent entity does not hide children #838

@AlexCMueller

Description

@AlexCMueller

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::*;

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

fn setup(
    mut commands: Commands,
    mut materials: 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()
            });
        });
}

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenA-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