-
-
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
[Merged by Bors] - Added multi windows check for bevy_ui Interaction
.
#5225
[Merged by Bors] - Added multi windows check for bevy_ui Interaction
.
#5225
Conversation
`Interaction` focus system will get first available window's cursor position instead of just primary window.
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 is a situation that this handles poorly:
You have two windows:
- Window 1 with UI elements
- Window 2 without the UI elements
When the mouse hovers over Window 2 I believe, this patch will activate the button under the corresponding position in Window 1.
I suggest this alternative: get the Window
for windows.get(id)
where id
is the target: RenderTarget::Window(WindowId)
field of the Camera
component of the entity with the CameraUi
marker component. Probably requires adding a query to ui_focus_system
or store the ID in an additional resource.
This is more difficult, because you can have multiple ui cameras. I think currently, it would be fine to take the windows id of the first ui camera and keep the issue open. A design that accounts for all ui cameras might be way harder to handle properly.
Now the focus system will consider the currently focused window instead of all window
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.
I think we should limit the query to stuff with a CameraUi
component. Otherwise, we might pick up other types of camera.
crates/bevy_ui/src/focus.rs
Outdated
if let Some(&CameraUi { | ||
is_enabled: false, .. | ||
}) = camera_ui | ||
{ | ||
return None; | ||
} |
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.
With the change suggested on the query parameter, you can replace this with if !camera_ui.is_enabled
.
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.
The user are able to add in any camera without this component.
Give me a minute and I'll give you a third review. |
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'd like this merged
This enables having different UI per camera. With bevyengine#5225, this enables having different interactive UIs per window. Although, to properly complete this, the focus system will need to account for RenderLayer of UI nodes.
This enables having different UI per camera. With bevyengine#5225, this enables having different interactive UIs per window. Although, to properly complete this, the focus system will need to account for RenderLayer of UI nodes.
This enables having different UI per camera. With bevyengine#5225, this enables having different interactive UIs per window. Although, to properly complete this, the focus system will need to account for RenderLayer of UI nodes.
bors r+ |
# Objective - Currently bevy_ui only checks for primary window cursor position to determine `Interaction` behavior. - Added checks for focused window where cursor position is available. - Fixes #5224. ## Solution - Added checks for focused windows in `Interaction` focus system. ## Follow Up - All windows with camera will be rendering the UI elements right now. - We will need some way to tell which camera to render which UI. --- Co-authored-by: fadhliazhari <44402264+fadhliazhari@users.noreply.github.com>
Interaction
.Interaction
.
This enables having different UI per camera. With bevyengine#5225, this enables having different interactive UIs per window. Although, to properly complete this, the focus system will need to account for RenderLayer of UI nodes.
This enables having different UI per camera. With bevyengine#5225, this enables having different interactive UIs per window. Although, to properly complete this, the focus system will need to account for RenderLayer of UI nodes.
This enables having different UI per camera. With bevyengine#5225, this enables having different interactive UIs per window. Although, to properly complete this, the focus system will need to account for RenderLayer of UI nodes.
# Objective - Currently bevy_ui only checks for primary window cursor position to determine `Interaction` behavior. - Added checks for focused window where cursor position is available. - Fixes bevyengine#5224. ## Solution - Added checks for focused windows in `Interaction` focus system. ## Follow Up - All windows with camera will be rendering the UI elements right now. - We will need some way to tell which camera to render which UI. --- Co-authored-by: fadhliazhari <44402264+fadhliazhari@users.noreply.github.com>
# Objective - Currently bevy_ui only checks for primary window cursor position to determine `Interaction` behavior. - Added checks for focused window where cursor position is available. - Fixes bevyengine#5224. ## Solution - Added checks for focused windows in `Interaction` focus system. ## Follow Up - All windows with camera will be rendering the UI elements right now. - We will need some way to tell which camera to render which UI. --- Co-authored-by: fadhliazhari <44402264+fadhliazhari@users.noreply.github.com>
# Objective - Currently bevy_ui only checks for primary window cursor position to determine `Interaction` behavior. - Added checks for focused window where cursor position is available. - Fixes bevyengine#5224. ## Solution - Added checks for focused windows in `Interaction` focus system. ## Follow Up - All windows with camera will be rendering the UI elements right now. - We will need some way to tell which camera to render which UI. --- Co-authored-by: fadhliazhari <44402264+fadhliazhari@users.noreply.github.com>
Objective
Interaction
behavior.Solution
Interaction
focus system.Follow Up