-
-
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
Camera-driven UI #10559
Camera-driven UI #10559
Conversation
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
I believe this PR could also close #5476. Since you could now render it to a texture and render that texture to a world space quad |
CI is failing because you need to run rustfmt |
I will clean up the examples and figure out why tests are failing in the upcoming few days. |
I've discovered that the tests are failing due to nodes not being added to the |
I have something I'm working on I need to finish urgently but once that's done (hopefully finished today), I'll do an in-depth review. These are changes I've really wanted for a long time. |
IMO we remove this in this PR too. |
Done removing |
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.
LGTM. i backported this to bevy 0.12 and have been using it in my work project.
i haven't thoroughly tested the scale factor changes, but the basic functionality works as intended and is super useful.
It looks like your PR is a breaking change, but you didn't provide a migration guide. Could you add some context on what users should update when this change get released in a new version of Bevy? |
# Objective - Fixes #13687 ## Solution - Text rendering in UI is still dependent on the `PrimaryWIndow` - implements #10559 for text rendering There are other parts of UI that are still `PrimaryWindow` dependent, if the changes here are OK I'll apply them everywhere. I'm not a fan of the `EntityHashMap` here to hold the scale factors, but it seems the quick and easy fix ## Testing - Run example `multiple_windows` on a screen with a scale factor different than 1, close the primary window
Objective
Add support for presenting each UI tree on a specific window and viewport, while making as few breaking changes as possible.
This PR is meant to resolve the following issues at once, since they're all related.
Adopted #5892 , but started over since the current codebase diverged significantly from the original PR branch. Also, I made a decision to propagate component to children instead of recursively iterating over nodes in search for the root.
Solution
Add a new optional component that can be inserted to UI root nodes and propagate to children to specify which camera it should render onto. This is then used to get the render target and the viewport for that UI tree. Since this component is optional, the default behavior should be to render onto the single camera (if only one exist) and warn of ambiguity if multiple cameras exist. This reduces the complexity for users with just one camera, while giving control in contexts where it matters.
Changelog
TargetCamera(Entity)
component to specify which camera should a node tree be rendered into. If only one camera exists, this component is optional.UiCameraConfig
. UI visibility now can be controlled via combination of explicitTargetCamera
andVisibility
on the root nodes.Migration Guide
If the world contains more than one camera, insert
TargetCamera(Entity)
component to each UI root node, whereEntity
is the ID of the camera you want this specific UI tree to be rendered to. Test for any required adjustments of UI positioning and scaling.Remove
UiCameraConfig
component from all cameras. If it was used to control UI visibility, insertVisibility
component on UI root nodes instead.