godot-proposals icon indicating copy to clipboard operation
godot-proposals copied to clipboard

Add a way to preview subviewports in the 2D editor

Open AndreaTerenz opened this issue 3 years ago • 5 comments

Describe the project you are working on

3D fps in Godot 3.5 (I'd say this applies to Godot 4 as well)

Describe the problem or limitation you are having in your project

I sometimes use Viewports with Control children to display UI in 3D in various ways and editing the UI nodes is impossible once they are children of a Viewport, because that means they won't show up in the 2D editor. What I have to do is move them out of and back into the viewport when I want to make any edit or change. A ViewportContainer doesn't help because:

  • it simply shows the content of a viewport as a static image
  • it's visible in game (this is an editor thing)
  • it shows up amongst any other 2D node

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Implement a dropdown menu in the 2D editor to select the Viewport you want to display (defaulting to the root viewport) in order to see and edit its 2D children nodes.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

mockup Under the hood, the editor would keep track of any viewports that are currently present in the scene to generate the dropdown

If this enhancement will not be used often, can it be worked around with a few lines of script?

I don't think so, it seems like a core editor feature.

Is there a reason why this should be core and not an add-on in the asset library?

Refer to previous question.

AndreaTerenz avatar Sep 14 '22 15:09 AndreaTerenz

Unless I misunderstood something, this proposal is already fullfilled. You can already preview SubViewports in the Inspector as well as in the general 2D viewport if they are rendered to a texture via ViewportTexture.

I think this can be closed.

golddotasksquestions avatar May 23 '23 09:05 golddotasksquestions

if they are rendered to a texture via ViewportTexture.

That's a big IF.

They want to see Viewport contents in the editor itself without having to fiddle with ViewportTextures. IIRC this is a bug that was fixed at some point though?

Zireael07 avatar May 23 '23 11:05 Zireael07

I actually ran into this problem but saving the branch under the subviewport as its own node with a control node as the root seems to be a solid work around for me. Its still a bug that the subviewport can't be in the 2D editor but thought I'd throw this out there just in case anyone is waiting for this.

warrenscipio avatar Sep 14 '24 07:09 warrenscipio

saving the branch under the subviewport as its own node with a control node as the root seems to be a solid work around for me

It is because it allows you to view that UI on its own, but it would be really cumbersome to have dozens of tiny UI scenes all over the place just to view their Control nodes in the editor

AndreaTerenz avatar Sep 16 '24 20:09 AndreaTerenz

saving the branch under the subviewport as its own node with a control node as the root seems to be a solid work around for me

It is because it allows you to view that UI on its own, but it would be really cumbersome to have dozens of tiny UI scenes all over the place just to view their Control nodes in the editor

If you plan to use dozens of subviewports than yes but you'd only need one per subviewport, having the contents of any subviewport being it's own scene doesn't seem that unreasonable, seems like it would promote good composition and project organization. But I also don't really have a project where I have dozens of subviewports, I've only really used them for diegetic UI so I'll have 2 or 3 max in an entire project.

warrenscipio avatar Sep 16 '24 23:09 warrenscipio

saving the branch under the subviewport as its own node with a control node as the root seems to be a solid work around for me.

In my case, I need functionality involving sending signals from the viewport in the editor. Is this possible with this workaround? If it is, how so?

Orisphera avatar Apr 20 '25 18:04 Orisphera

I think this is implementable by copying some code from the 3D editor to the 2D editor. Depending on the policy, it may be better to make it share the code between the editors

Orisphera avatar Apr 21 '25 19:04 Orisphera

Another, better IMO but by my estimation harder to implement, similar idea: it should be possible to edit contents of viewports (such as tilemap layers in them) in the scene in which the mesh with the viewport material with it is, and some way of specifying that a tilemap layer is based on another one (automatically updates to something based on it with a script) should also be implemented so that they can be edited like that, too

Orisphera avatar Apr 21 '25 19:04 Orisphera

@Orisphera PS: In the future, please use the Edit button (located behind the icon in the top-right corner of your comments) instead of multi-posting.

Calinou avatar Apr 21 '25 20:04 Calinou

@Orisphera PS: In the future, please use the Edit button (located behind the icon in the top-right corner of your comments) instead of multi-posting.

I don't think that's a good idea because I think it would be better in such cases as this if the old comment remained

Orisphera avatar May 20 '25 17:05 Orisphera

I don't think that's a good idea because I think it would be better in such cases as this if the old comment remained

What I mean is that you can append the new text to the existing comment, instead of replacing it 🙂

Calinou avatar May 20 '25 20:05 Calinou

I don't think that's a good idea because I think it would be better in such cases as this if the old comment remained

What I mean is that you can append the new text to the existing comment, instead of replacing it 🙂

How should I separate them?

Orisphera avatar Jun 02 '25 08:06 Orisphera