fn target_cameras(
mut commands: Commands,
mut count: Local<usize>,
mut query: Query<&mut TargetCamera, With<Parent>>,
) {
*count += 1;
if *count == 2 {
// spawn a UI camera!
let ui_camera = commands
.spawn(Camera2dBundle {
camera: Camera {
order: 10,
..Default::default()
},
..Default::default()
})
.id();
for mut c in query.iter_mut() {
c.0 = ui_camera;
}
}
}
What went wrong
Non-root TargetCameras are meant to have no effect but update_target_camera_system only does an update if it detects changes to the root node's TargetCamera and not the TargetCamera components of any of the rest of the entities in the UI node tree.
I think the fix is to probably to not update the target cameras components at all, and instead have a resolved_camera_entity field in Node or something.
Bevy version
main
What you did
Added this system to
render_ui_to_texture
:What went wrong
Non-root
TargetCamera
s are meant to have no effect butupdate_target_camera_system
only does an update if it detects changes to the root node'sTargetCamera
and not theTargetCamera
components of any of the rest of the entities in the UI node tree.