Creates a sub-view into the screen.
    public class Viewport : Node

A Viewport creates a different view into the screen, or a sub-view inside another viewport. Children 2D Nodes will display on it, and children Camera 3D nodes will render on it too.

Optionally, a viewport can have its own 2D or 3D world, so they don’t share what they draw with other viewports.

If a viewport is a child of a Control, it will automatically take up its same rect and position, otherwise they must be set manually.

Viewports can also choose to be audio listeners, so they generate positional audio depending on a 2D or 3D camera child of it.

Also, viewports can be assigned to different screens in case the devices have multiple screens.

Finally, viewports can also behave as render targets, in which case they will not be visible unless the associated texture is used to draw.

Inheritance Chain


    public Viewport()


    "size_changed" ()

Emitted when the size of the viewport is changed, whether by SetSizeOverride(bool, Godot.Vector2?, Godot.Vector2?), resize of window, or some other means.


    public bool Arvr { get; set; }

    public bool AudioListenerEnable2d { get; set; }

    public bool AudioListenerEnable3d { get; set; }

    public Transform2D CanvasTransform { get; set; }

The canvas transform of the viewport, useful for changing the on-screen positions of all child CanvasItems. This is relative to the global canvas transform of the viewport.

    public DebugDrawEnum DebugDraw { get; set; }

    public bool Disable3d { get; set; }

    public Transform2D GlobalCanvasTransform { get; set; }

The global canvas transform of the viewport. The canvas transform is relative to this.

    public bool GuiDisableInput { get; set; }

    public bool GuiSnapControlsToPixels { get; set; }

    public bool Hdr { get; set; }

    public MSAA Msaa { get; set; }

    public bool OwnWorld { get; set; }

    public bool PhysicsObjectPicking { get; set; }

    public ClearMode RenderTargetClearMode { get; set; }

    public UpdateMode RenderTargetUpdateMode { get; set; }

    public bool RenderTargetVFlip { get; set; }

    public ShadowAtlasQuadrantSubdiv ShadowAtlasQuad0 { get; set; }

    public ShadowAtlasQuadrantSubdiv ShadowAtlasQuad1 { get; set; }

    public ShadowAtlasQuadrantSubdiv ShadowAtlasQuad2 { get; set; }

    public ShadowAtlasQuadrantSubdiv ShadowAtlasQuad3 { get; set; }

    public int ShadowAtlasSize { get; set; }

    public Vector2 Size { get; set; }

    public bool TransparentBg { get; set; }

    public UsageEnum Usage { get; set; }

    public World World { get; set; }

    public World2D World2d { get; set; }


    public World FindWorld()

Return the 3D world of the viewport, or if no such present, the one of the parent viewport.

    public World2D FindWorld2d()

Return the 2D world of the viewport.

    public Camera GetCamera()

Return the active 3D camera.

    public Transform2D GetCanvasTransform()

Getter for CanvasTransform

    public ClearMode GetClearMode()

Getter for RenderTargetClearMode

    public DebugDrawEnum GetDebugDraw()

Getter for DebugDraw

    public Transform2D GetFinalTransform()

Get the total transform of the viewport.

    public Transform2D GetGlobalCanvasTransform()

Getter for GlobalCanvasTransform

    public bool GetHdr()

Getter for Hdr

    public Vector2 GetMousePosition()

Get the mouse position, relative to the viewport.

    public MSAA GetMsaa()

Getter for Msaa

    public bool GetPhysicsObjectPicking()

Getter for PhysicsObjectPicking

    public int GetRenderInfo(RenderInfo info)

    public ShadowAtlasQuadrantSubdiv GetShadowAtlasQuadrantSubdiv(int quadrant)

    public int GetShadowAtlasSize()

Getter for ShadowAtlasSize

    public Vector2 GetSize()

Getter for Size

    public Vector2 GetSizeOverride()

Get the size override set with SetSizeOverride(bool, Godot.Vector2?, Godot.Vector2?).

    public ViewportTexture GetTexture()

Get the viewport’s texture, for use with various objects that you want to texture with the viewport.

    public UpdateMode GetUpdateMode()

Getter for RenderTargetUpdateMode

    public UsageEnum GetUsage()

Getter for Usage

    public bool GetVflip()

Getter for RenderTargetVFlip

    public RID GetViewportRid()

Get the viewport RID from the VisualServer.

    public Rect2 GetVisibleRect()

Return the final, visible rect in global screen coordinates.

    public World GetWorld()

Getter for World

    public World2D GetWorld2d()

Getter for World2d

    public object GuiGetDragData()

Returns the drag data from the GUI, that was previously returned by Control.GetDragData(Godot.Vector2).

    public bool GuiHasModalStack()

Returns whether there are shown modals on-screen.

    public bool HasTransparentBackground()

Getter for TransparentBg

    public void Input(InputEvent localEvent)

    public bool Is3dDisabled()

Getter for DebugDrawEnum.Disabled

    public bool IsAudioListener()

Getter for AudioListenerEnable2d

    public bool IsAudioListener2d()

Getter for AudioListenerEnable2d

    public bool IsInputDisabled()

Getter for GuiDisableInput

    public bool IsSizeOverrideEnabled()

Get the enabled status of the size override set with SetSizeOverride(bool, Godot.Vector2?, Godot.Vector2?).

    public bool IsSizeOverrideStretchEnabled()

Get the enabled status of the size strech override set with SetSizeOverrideStretch(bool).

    public bool IsSnapControlsToPixelsEnabled()

Getter for GuiSnapControlsToPixels

    public bool IsUsingOwnWorld()

Getter for OwnWorld

    public void SetAsAudioListener(bool enable)

Setter for AudioListenerEnable2d

    public void SetAsAudioListener2d(bool enable)

Setter for AudioListenerEnable2d

    public void SetAttachToScreenRect(Rect2 rect)

    public void SetCanvasTransform(Transform2D xform)

Setter for CanvasTransform

    public void SetClearMode(ClearMode mode)

Setter for RenderTargetClearMode

    public void SetDebugDraw(DebugDrawEnum debugDraw)

Setter for DebugDraw

    public void SetDisable3d(bool disable)

Setter for DebugDrawEnum.Disabled

    public void SetDisableInput(bool disable)

Setter for GuiDisableInput

    public void SetGlobalCanvasTransform(Transform2D xform)

Setter for GlobalCanvasTransform

    public void SetHdr(bool enable)

Setter for Hdr

    public void SetMsaa(MSAA msaa)

Setter for Msaa

    public void SetPhysicsObjectPicking(bool enable)

Setter for PhysicsObjectPicking

    public void SetShadowAtlasQuadrantSubdiv(int quadrant, ShadowAtlasQuadrantSubdiv subdiv)

    public void SetShadowAtlasSize(int size)

Setter for ShadowAtlasSize

    public void SetSize(Vector2 size)

Setter for Size

    public void SetSizeOverride(bool enable, Vector2? size = default(Vector2?), Vector2? margin = default(Vector2?))

Set the size override of the viewport. If the enable parameter is true, it would use the override, otherwise it would use the default size. If the size parameter is equal to (-1, -1), it won’t update the size.

    public void SetSizeOverrideStretch(bool enabled)

Set whether the size override affects stretch as well.

    public void SetSnapControlsToPixels(bool enabled)

Setter for GuiSnapControlsToPixels

    public void SetTransparentBackground(bool enable)

Setter for TransparentBg

    public void SetUpdateMode(UpdateMode mode)

Setter for RenderTargetUpdateMode

    public void SetUsage(UsageEnum usage)

Setter for Usage

    public void SetUseArvr(bool use)

Setter for Arvr

    public void SetUseOwnWorld(bool enable)

Setter for OwnWorld

    public void SetVflip(bool enable)

Setter for RenderTargetVFlip

    public void SetWorld(World world)

Setter for World

    public void SetWorld2d(World2D world2d)

Setter for World2d

    public void UnhandledInput(InputEvent localEvent)

    public void UpdateWorlds()

Force update of the 2D and 3D worlds.

    public bool UseArvr()

Getter for Arvr

    public void WarpMouse(Vector2 toPosition)

Warp the mouse to a position, relative to the viewport.

Inner Types


Name Value Description
Always 0  
Never 1  
OnlyNextFrame 2  


Name Value Description
Disabled 0  
Unshaded 1  
Overdraw 2  
Wireframe 3  


Name Value Description
Disabled 0  


Name Value Description
ObjectsInFrame 0  
VerticesInFrame 1  
MaterialChangesInFrame 2  
ShaderChangesInFrame 3  
SurfaceChangesInFrame 4  
DrawCallsInFrame 5  
Max 6  


Name Value Description
Disabled 0  
Max 7  


Name Value Description
Disabled 0 Do not update the render target.
Once 1 Update the render target once, then switch to [code]UPDATE_DISABLED[/code]
WhenVisible 2 Update the render target only when it is visible. This is the default value.
Always 3  


Name Value Description