godot-extended-libraries/godot-debug-menu

Can't render the menu in a SubViewport

synalice opened this issue · 2 comments

Prerequisites:

  • display/window/size/viewport_width = 640
  • display/window/size/viewport_height = 360
  • display/window/size/window_width_override = 1280
  • display/window/size/window_height_override = 720
  • display/window/stretch/mode = "viewport"
  • display/window/stretch/aspect = "expand"

The issue:
With the settings above, I've managed to achieve the desired PS1 style of the game. Unfortunately, your debug menu now also looks scaled-down because of this. It's completely unreadable.

What I've tried:
The Godot's documentation suggests using a SubViewport node to overcome this exact problem.

Unfortunately, when I try to place debug_menu.tscn inside this node and then press F3 while in the game, the menu's script breaks on the line 172 (if viewport.content_scale_mode == Window.CONTENT_SCALE_MODE_VIEWPORT:) with the following error: Invalid get index 'content_scale_mode' (on base: 'SubViewport').

How can I render the debug menu inside a separate viewport so that it is displayed in higher resolution than everything else in the game? Thanks in advance!

This is indeed not an use case I accounted for when developing the debug menu. You'll probably want to switch to native resolution (canvas_items stretch mode) when using the debug menu (as this is where most GPU-bottlenecked scenarios occur). It's much rarer to be GPU-bottlenecked with a viewport that is only 640×360 in comparison.

debug_menu.tscn is an autoloaded scene, so it's not designed to be manually instanced in a scene. If you do that, you'll end up with two instances at once and both will appear at the same time when pressing F3. A proper solution will likely involve DebugMenu creating its own viewport on-demand (but only when the project uses the viewport stretch mode, as this has a performance cost).

Turn's out (as it always happens), I didn't read the documentation good enough. It clearly tells you to use the root Viewport (default settings, no SubViewport node) for everything UI and a SubViewport node for a 3D scenes.

I've changed my project settings to this...

  • display/window/size/viewport_width = 1280
  • display/window/size/viewport_height = 720
  • display/window/size/window_width_override = 0
  • display/window/size/window_height_override = 0
  • display/window/stretch/mode = "canvas_items"
  • display/window/stretch/aspect = "expand"

...and placed every 3D scene into this node structure:

SubViewportContainer
|__SubViewport
   |__MyAwesome3DScene

To scale down my game, I just set SubViewportContainer's stretch property to true and bump stretch_shrink to something like 2 or 3.

The menu seems to be working fine, so the issue is solved for me.