-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Disable camera on window close #8802
Conversation
@@ -520,6 +526,18 @@ pub fn camera_system<T: CameraProjection + Component>( | |||
) { | |||
let primary_window = primary_window.iter().next(); | |||
|
|||
// Disable the camera associated to a window that's just been closed | |||
for ev in window_close_events.iter() { | |||
for (mut camera, _) in &mut cameras { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use query.get_mut here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There could be multiple camera per window, like for split screen. Also, the window doesn't have a camera entity id. It's the camera that contains a reference to the window.
This feels slightly off to me. Camera "activeness" is user-provided configuration that happens to result in camera outputs being rendered. I think it makes more sense to transparently skip rendering without touching user configuration (aka do the skip on the render app side). Otherwise this will probably lead to weird / unexpected behaviors. For example: if you remove the "primary window" and then re-add it, it seems like this PR would result in default cameras not silently not working when the primary window is respawned. The user would need to know to re-activate the cameras manually. |
Right, I see what you mean. I'll see if there's a cleaner way to do this then. |
7c8454a
to
d515786
Compare
Alright @cart that was a good call. I now disable it just before running the graph. It's a lot more transparent for the user and seems like a cleaner fix. |
Objective
Solution
Notes
It's possible a similar thing could be done for camera that use an image handle, but I would fix that in a separate PR.