bevy/examples/window
Roman Salnikov eb9db21113
Camera-driven UI (#10559)
# 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.

- Fixes #5622 
- Fixes #5570 
- Fixes #5621 

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

- Adds `TargetCamera(Entity)` component to specify which camera should a
node tree be rendered into. If only one camera exists, this component is
optional.
- Adds an example of rendering UI to a texture and using it as a
material in a 3D world.
- Fixes recalculation of physical viewport size when target scale factor
changes. This can happen when the window is moved between displays with
different DPI.
- Changes examples to demonstrate assigning UI to different viewports
and windows and make interactions in an offset viewport testable.
- Removes `UiCameraConfig`. UI visibility now can be controlled via
combination of explicit `TargetCamera` and `Visibility` on the root
nodes.

---------

Co-authored-by: davier <bricedavier@gmail.com>
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Co-authored-by: Alice Cecile <alice.i.cecil@gmail.com>
2024-01-16 00:39:10 +00:00
..
clear_color.rs Rename Input to ButtonInput (#10859) 2023-12-06 20:32:34 +00:00
low_power.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
multiple_windows.rs Camera-driven UI (#10559) 2024-01-16 00:39:10 +00:00
scale_factor_override.rs Update winit dependency to 0.29 (#10702) 2023-12-21 07:40:47 +00:00
screenshot.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
transparent_window.rs Fix doc link in transparent_window example (#9697) 2023-09-05 05:43:26 +00:00
window_resizing.rs Update winit dependency to 0.29 (#10702) 2023-12-21 07:40:47 +00:00
window_settings.rs Remove CanvasParentResizePlugin (#11057) 2023-12-21 20:01:22 +00:00