VisualServerViewportAttachToScreen Method |
Copies viewport to a region of the screen specified by rect. If RenderDirectToScreen is true, then viewport does not use a framebuffer and the contents of the viewport are rendered directly to screen. However, note that the root viewport is drawn last, therefore it will draw over the screen. Accordingly, you must set the root viewport to an area that does not cover the area that you have attached this viewport to.
For example, you can set the root viewport to not render at all with the following code:
func _ready(): get_viewport().set_attach_to_screen_rect(Rect2()) $Viewport.set_attach_to_screen_rect(Rect2(0, 0, 600, 600))
Using this can result in significant optimization, especially on lower-end devices. However, it comes at the cost of having to manage your viewports manually. For a further optimization see, ViewportSetRenderDirectToScreen(RID, Boolean).
Namespace: Godot
public static void ViewportAttachToScreen( RID viewport, Rect2? rect = null, int screen = 0 )
[Missing <param name="viewport"/> documentation for "M:Godot.VisualServer.ViewportAttachToScreen(Godot.RID,System.Nullable{Godot.Rect2},System.Int32)"]
[Missing <param name="screen"/> documentation for "M:Godot.VisualServer.ViewportAttachToScreen(Godot.RID,System.Nullable{Godot.Rect2},System.Int32)"]