Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

SubViewport

Inherits: Viewport < Node < Object

An interface to a game world that doesn't create a window or draw to the screen directly.

Description

SubViewport Isolates a rectangular region of a scene to be displayed independently. This can be used, for example, to display UI in 3D space.

Note: SubViewport is a Viewport that isn't a Window, i.e. it doesn't draw anything by itself. To display anything, SubViewport must have a non-zero size and be either put inside a SubViewportContainer or assigned to a ViewportTexture.

Tutorials

Properties

ClearMode

render_target_clear_mode

0

UpdateMode

render_target_update_mode

2

Vector2i

size

Vector2i(512, 512)

Vector2i

size_2d_override

Vector2i(0, 0)

bool

size_2d_override_stretch

false


Enumerations

enum ClearMode:

ClearMode CLEAR_MODE_ALWAYS = 0

Always clear the render target before drawing.

ClearMode CLEAR_MODE_NEVER = 1

Never clear the render target.

ClearMode CLEAR_MODE_ONCE = 2

Clear the render target on the next frame, then switch to CLEAR_MODE_NEVER.


enum UpdateMode:

UpdateMode UPDATE_DISABLED = 0

Do not update the render target.

UpdateMode UPDATE_ONCE = 1

Update the render target once, then switch to UPDATE_DISABLED.

UpdateMode UPDATE_WHEN_VISIBLE = 2

Update the render target only when it is visible. This is the default value.

UpdateMode UPDATE_WHEN_PARENT_VISIBLE = 3

Update the render target only when its parent is visible.

UpdateMode UPDATE_ALWAYS = 4