Skip to content
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

Support multiple UI roots #5622

Closed
Weibye opened this issue Aug 8, 2022 · 1 comment · Fixed by #10559
Closed

Support multiple UI roots #5622

Weibye opened this issue Aug 8, 2022 · 1 comment · Fixed by #10559
Labels
A-UI Graphical user interfaces, styles, layouts, and widgets C-Feature A new feature, making something new possible

Comments

@Weibye
Copy link
Contributor

Weibye commented Aug 8, 2022

What problem does this solve or what need does it fill?

In order to support #5570 or #5621 we need a way to define multiple separate UI trees. Each UI root should have data defining which window, viewport and / or render layer they belong to.

I think the best way of handling it would be to support multiple UI roots with an explicit component that also encodes the settings for the whole tree under the root. This would be one place to specify the RenderLayer (or for a better higher level API: specify the camera that renders the UI under the root)

Originally posted by @nicopap in #5414 (comment)

@Weibye Weibye added C-Feature A new feature, making something new possible A-UI Graphical user interfaces, styles, layouts, and widgets labels Aug 8, 2022
@djeedai
Copy link
Contributor

djeedai commented Aug 17, 2022

For context, Draft PR #1211 has plenty of discussion.

@Weibye Weibye moved this to Todo in UI Aug 18, 2022
@Weibye Weibye added this to UI Aug 18, 2022
github-merge-queue bot pushed a commit that referenced this issue Jan 16, 2024
# 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>
@github-project-automation github-project-automation bot moved this from Todo to Done in UI Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-UI Graphical user interfaces, styles, layouts, and widgets C-Feature A new feature, making something new possible
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants