Skip to content

Conversation

@MushineLament
Copy link
Contributor

@MushineLament MushineLament commented Nov 12, 2025

Preface

Added feature 'bevy_ui_container' to ensure normal functioning of other functions

Objective

Fixes #21278
Try #5476

Existing problems:

  • Fix node rotation
  • UiTransform based on UiContain Transform
  • Layout based on UiContain size
  • UiContainTarget passes to child nodes
  • Support Anchor
  • UiContain Support Overflow
  • Node click
  • performance optimization

...

Expectations and difficulties:

  1. Non root nodes take effect (May affect the entire Node)
  2. UiContain supports Visibility (Restricted by the relationship of visibility)

Solution

1.Ui follows the world from a point (Transfrom) to move
2.Modify Ui Layout Size Source (UiContainerSize)
3.Place Node in UiContainer for rendering(Use UiContainerTarget to specify Container)

Testing

  • Did you test these changes? If so, how?
    I changed the UiSurface Resource that Node relies on in the test to Component, and its result is consistent with the Camera Node.

  • Are there any parts that need more testing?

  1. The Button function of Container Node may need to be tested
  2. Is there a performance issue
  3. Does screen scaling affect the proper functioning of containers
  4. Zindex has not been tested

Showcase

Quicker_20251116_215832

@github-actions
Copy link
Contributor

Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke!
You can review it at https://pixel-eagle.com/project/B04F67C0-C054-4A6F-92EC-F599FEC2FD1D?filter=PR-21812

If it's expected, please add the M-Deliberate-Rendering-Change label.

If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it.

@github-actions
Copy link
Contributor

Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke!
You can review it at https://pixel-eagle.com/project/B04F67C0-C054-4A6F-92EC-F599FEC2FD1D?filter=PR-21812

If it's expected, please add the M-Deliberate-Rendering-Change label.

If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it.

@github-actions
Copy link
Contributor

Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke!
You can review it at https://pixel-eagle.com/project/B04F67C0-C054-4A6F-92EC-F599FEC2FD1D?filter=PR-21812

If it's expected, please add the M-Deliberate-Rendering-Change label.

If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it.

@ickshonpe
Copy link
Contributor

The example needs to be run with the "bevy_ui_container" feature enabled:

cargo run --example ui_container --features bevy/bevy_ui_container

Otherwise it doesn't work correctly.

MushineLament and others added 2 commits November 18, 2025 08:46
example required features bevy_ui_container

Co-authored-by: ickshonpe <david.curthoys@googlemail.com>
fix word error

Co-authored-by: ickshonpe <david.curthoys@googlemail.com>
Copy link
Contributor

@ickshonpe ickshonpe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the feature gate should be removed, world UI is fairly fundamental and probably not something that should be feature gated.

And also just for this PR, it adds a lot of extra noise that makes the changes more difficult to review.

fix word error

Co-authored-by: ickshonpe <david.curthoys@googlemail.com>
@MushineLament
Copy link
Contributor Author

MushineLament commented Nov 18, 2025

I think the feature gate would probably be better removed, world UI is fairly fundamental and probably not something that should be feature gated.

And also just for this PR, it adds a lot of extra nouse that makes the changes more difficult to review.

Yes, perhaps we need to open a new create or plugin?
I think I can try. I have come up with a solution

});
#[cfg(feature = "bevy_ui_container")]
{
let Ok(view) = camera_views.get(default_camera_view.ui_container) else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right, if you run:
cargo run --example testbed_ui --features bevy/bevy_ui_container
there are visual artifacts which seem to result from drawing some of the phase items twice?
There are similar problems with the other queue_* functions.

@MushineLament
Copy link
Contributor Author

@ickshonpe
I have reduced the extra noise and will migrate to the new plugin. To be honest, I don't want to remove the feature gate.

Mushine Lament added 2 commits November 18, 2025 20:58
let Ok((scale, size)) = query_ui_scale.get(target.0) else {
return;
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it "return"? Shouldn't it be "continue"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rendering code for the UiContainer still has some issues. This is related to the UiCameraView, which necessitates the existence of both UiCamera and UiContainer. I plan to decouple them to reduce dependency and improve performance.

@alice-i-cecile
Copy link
Member

I don't want this feature-gated either. I think it adds complexity, and makes it harder to reason about how layout works.

@MushineLament
Copy link
Contributor Author

我也不希望这个功能被限制。我觉得这增加了复杂性,也让理解布局的运作变得更难。

Since the majority of the members agree, I plan to remove the feature gate.

@github-actions
Copy link
Contributor

Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke!
You can review it at https://pixel-eagle.com/project/B04F67C0-C054-4A6F-92EC-F599FEC2FD1D?filter=PR-21812

If it's expected, please add the M-Deliberate-Rendering-Change label.

If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it.

1 similar comment
@github-actions
Copy link
Contributor

Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke!
You can review it at https://pixel-eagle.com/project/B04F67C0-C054-4A6F-92EC-F599FEC2FD1D?filter=PR-21812

If it's expected, please add the M-Deliberate-Rendering-Change label.

If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it.

@SuitedRioter
Copy link

Judging from your modifications to UiSurface and UiScale, it appears that your PR lacks a systematic approach to bevy_ui. Instead, it seems you made changes based on a targeted look at certain parts of the code, resulting in several adjustments that do not align with Bevy’s current architecture and design principles. Therefore, I suggest you first explain your design approach, discuss it with the team, and then proceed with the changes before submitting the PR.

@MushineLament
Copy link
Contributor Author

Judging from your modifications to UiSurface and UiScale, it appears that your PR lacks a systematic approach to bevy_ui. Instead, it seems you made changes based on a targeted look at certain parts of the code, resulting in several adjustments that do not align with Bevy’s current architecture and design principles. Therefore, I suggest you first explain your design approach, discuss it with the team, and then proceed with the changes before submitting the PR.

Yes, there is indeed this issue. My design solution is based on an idea: since the UI is laid out relative to the camera—where the camera acts as a "container for the UI"—and this container always follows the camera, why not define a container in world space to hold the UI and make the UI follow this container? For this purpose, I designed UiContainerSize, which corresponds to the layout size of the camera.

After considering the above, I distinguish between UI laid out in world space and UI laid out relative to the camera as ContainerUI (perhaps it could be called WorldUI?) and CameraUI, because there are slight differences between them, such as in the coordinate system.

(Regarding the multiple "fix ci" issues—I admit it's just a personal habit of preferring to make improvements on relatively correct and standardized code.)

@github-actions
Copy link
Contributor

Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke!
You can review it at https://pixel-eagle.com/project/B04F67C0-C054-4A6F-92EC-F599FEC2FD1D?filter=PR-21812

If it's expected, please add the M-Deliberate-Rendering-Change label.

If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it.

1 similar comment
@github-actions
Copy link
Contributor

Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke!
You can review it at https://pixel-eagle.com/project/B04F67C0-C054-4A6F-92EC-F599FEC2FD1D?filter=PR-21812

If it's expected, please add the M-Deliberate-Rendering-Change label.

If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it.

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 M-Release-Note Work that should be called out in the blog due to impact S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged X-Controversial There is active debate or serious implications around merging this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UiSurface should implement component,no just for the camera

5 participants