-
-
Notifications
You must be signed in to change notification settings - Fork 21.8k
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
Add viewport override to 2D editor #74573
base: master
Are you sure you want to change the base?
Conversation
3a32f19
to
f87e731
Compare
Ok this is somewhat finished. I fixed the viewport problems by adding more viewports. So the 2D editor structure is now SubViewportContainer -> SubViewport -> TextureRect -> current viewport. The current viewport is still displayed inside TextureRect, but screen transform is now different. While using main viewport, the displayed viewports' transform is changed. If the viewport is overriden, the containing viewport (the one under SubViewportContainer) is transformed instead and the overriding viewport is displayed in local space. It works quite well. godot.windows.editor.dev.x86_64_ajTVBn3MD9.mp4I'm really surprised that selecting nodes works without any problems in this setup. The only problem are Window nodes. For whatever reason they don't redraw when content changes and don't draw anything while invisible. godot.windows.editor.dev.x86_64_xk6EogJICc.mp4(I also remembered that the override button is buggy) But it's ready to be ready for review I think. EDIT: godot.windows.editor.dev.x86_64_vLvG7cbxP7.mp4 |
This is amazing, really need that one :) |
This comment was marked as off-topic.
This comment was marked as off-topic.
@Variable-ind Please don't bump issues without contributing significant new information. Use the 👍 reaction button on the first post instead. |
What's status of this? |
Needs testing and review. |
f87e731
to
19649e0
Compare
19649e0
to
cd73d6a
Compare
Tested locally, works good with some caveats you mentioned. Suggestion: how about not restricting rendering outside of the overridden viewport, as in a normal, not overridden one? |
This is a technical restriction. The main viewport works a bit differently - when you move around, its canvas is transformed and displays a different region. The rendering is still restricted to the viewport's size, but it has the size of the editor, so you don't see that objects outside don't render. |
Needs rebase, and then going around to poke people on #editor to actually get this reviewed :P |
cd73d6a
to
ec9cde1
Compare
ec9cde1
to
cfb57bb
Compare
Would this also work for 3D nodes with a 2D Subviewport? |
No, this doesn't cover 3D. |
Looks really good! |
Currently you have to select SubViewport node and click the button on the toolbar. You can preview any SubViewport in the scene using that. |
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.
Tested locally, it works as expected in all rendering methods.
It even works with viewports that contain 3D nodes, as long as it's previewed within the 2D editor 🙂
Some feedback:
- It's hard to distinguish between the button being disabled (when a non-Viewport node is selected), enabled, and active:
Disabled | Enabled | Active |
---|---|---|
![]() |
![]() |
![]() |
I suggest using a copy of the icon that is white, so that it's more visible (and there's higher contrast between the disabled and enabled state).
- There should be tooltip when hovering the aforementioned button. Something like this:
Viewport Override
Overrides the 2D editor view with the contents of the selected Viewport node.
This would match the tooltip of the Project Camera Override button nicely (which is right besides it).
cfb57bb
to
712b223
Compare
712b223
to
bab2fc7
Compare
Rebased, but the root viewport is bugged for some reason. Its ViewportTexture is smaller than the viewport, so the 2D editor view is cropped. |
bab2fc7
to
9ef9844
Compare
This PR supersedes #61873 with alternative approach.
Instead of enabling other viewports and fighting with the editor to make it work properly, I added a button that allows to override the default 2D editor viewport with another one.
viewport.override.mp4
I have one unresolved problem though - the overriding viewport's size must match the editor's size to display properly. Right now I'm just displaying its content with a TextureRect, but maybe I should use some different approach, idk.
I didn't make much progress for some time, so I'm opening a draft.
Closes godotengine/godot-proposals#2139
Closes godotengine/godot-proposals#5422