-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UI components not respecting RenderLayers #6069
Comments
I modified the bevy-ui-renderlayers-demo.mp4 |
I just found an acceptable workaround. You can add the |
Updated example change that demonstrates the issue: diff --git a/examples/3d/render_to_texture.rs b/examples/3d/render_to_texture.rs
index 81c687e5a..e4473bcae 100644
--- a/examples/3d/render_to_texture.rs
+++ b/examples/3d/render_to_texture.rs
@@ -35,6 +35,7 @@ fn setup(
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
mut images: ResMut<Assets<Image>>,
+ asset_server: Res<AssetServer>,
) {
let size = Extent3d {
width: 512,
@@ -141,6 +142,17 @@ fn setup(
transform: Transform::from_xyz(0.0, 0.0, 15.0).looking_at(Vec3::ZERO, Vec3::Y),
..default()
});
+
+ commands.spawn((
+ TextBundle::from_section(
+ "hello\nbevy!",
+ TextStyle {
+ font: asset_server.load("fonts/FiraSans-Bold.ttf"),
+ font_size: 200.0,
+ color: Color::RED,
+ },
+ ),
+ ));
}
/// Rotates the inner cube (first pass) |
Hmmm, when I added Adding it to the camera rendering to the image using |
Same problem. I use two cameras: one for classic game rendering, and second for rendering onto tile map (decals like blood texures, etc..). But when I spawn a Here's how I spawn text: world.spawn(
TextBundle::from_sections([
TextSection::new("FPS: ", style.clone()),
TextSection::from_style(style.clone()),
TextSection::new("\nEntities: ", style.clone()),
TextSection::from_style(style.clone()),
TextSection::new("\nAudio sources: ", style.clone()),
TextSection::from_style(style.clone()),
TextSection::new(
"\n\
\nSpawn weapon: [G]\
\nSpawn human : [H] group: [+SHIFT]\
\nSpawn zombie: [J] group: [+SHIFT]\
",
style,
),
])
); Here's how I spawn second camera (for tile map blending): commands
.spawn(Camera2dBundle {
camera: Camera {
target: RenderTarget::Image(target),
output_mode: CameraOutputMode::Write {
blend_state: Some(BlendState::PREMULTIPLIED_ALPHA_BLENDING),
color_attachment_load_op: LoadOp::Load,
},
..Default::default()
},
camera_2d: Camera2d {
clear_color: ClearColorConfig::None,
},
transform,
..Default::default()
})
.insert(RenderLayers::layer(1)); // NOTE: used different render layer But thanks to @paulkre workaround with |
The visibility of UI entities like text is not affected by the
RenderLayers
component. This is a problem when trying to prerender a scene withRenderTarget::Image
to use it as a mesh texture (the game UI will also be visible on the texture).Is there a way to make UI components respect
RenderLayers
?The text was updated successfully, but these errors were encountered: