Class Viewport
Abstract base class for viewports. Encapsulates drawing and interaction with a game world.
- Inheritance
-
Viewport
- Derived
Remarks
A Viewport creates a different view into the screen, or a sub-view inside another viewport. Child 2D nodes will display on it, and child Camera3D 3D nodes will render on it too.
Optionally, a viewport can have its own 2D or 3D world, so it doesn't share what it draws with other viewports.
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.
See Also
Properties
anisotropic_filtering_level
Sets the maximum number of samples to take when using anisotropic filtering on textures (as a power of two). A higher sample count will result in sharper textures at oblique angles, but is more expensive to compute. A value of 0
forcibly disables anisotropic filtering, even on materials where it is enabled.
The anisotropic filtering level also affects decals and light projectors if they are configured to use anisotropic filtering. See rendering/textures/decals/filter and rendering/textures/light_projectors/filter.
Note: In 3D, for this setting to have an effect, set texture_filter to BaseMaterial3D.TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC or BaseMaterial3D.TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC on materials.
Note: In 2D, for this setting to have an effect, set texture_filter to CanvasItem.TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC or CanvasItem.TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC on the CanvasItem node displaying the texture (or in CanvasTexture). However, anisotropic filtering is rarely useful in 2D, so only enable it for textures in 2D if it makes a meaningful visual difference.
var anisotropic_filtering_level : int = 2
Property Value
Remarks
audio_listener_enable_2d
If true
, the viewport will process 2D audio streams.
var audio_listener_enable_2d : bool = false
Property Value
Remarks
audio_listener_enable_3d
If true
, the viewport will process 3D audio streams.
var audio_listener_enable_3d : bool = false
Property Value
Remarks
canvas_cull_mask
The rendering layers in which this Viewport renders CanvasItem nodes.
var canvas_cull_mask : int = 4294967295
Property Value
Remarks
canvas_item_default_texture_filter
Sets the default filter mode used by CanvasItems in this Viewport. See DefaultCanvasItemTextureFilter for options.
var canvas_item_default_texture_filter : int = 1
Property Value
Remarks
canvas_item_default_texture_repeat
Sets the default repeat mode used by CanvasItems in this Viewport. See DefaultCanvasItemTextureRepeat for options.
var canvas_item_default_texture_repeat : int = 0
Property Value
Remarks
canvas_transform
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.
var canvas_transform : Transform2D
Property Value
Remarks
- void set_canvas_transform(Transform2D value)
- Transform2D get_canvas_transform
debug_draw
The overlay mode for test rendered geometry in debug purposes.
var debug_draw : int = 0
Property Value
Remarks
disable_3d
Disable 3D rendering (but keep 2D rendering).
var disable_3d : bool = false
Property Value
Remarks
fsr_sharpness
Determines how sharp the upscaled image will be when using the FSR upscaling mode. Sharpness halves with every whole number. Values go from 0.0 (sharpest) to 2.0. Values above 2.0 won't make a visible difference.
To control this property on the root viewport, set the rendering/scaling_3d/fsr_sharpness project setting.
var fsr_sharpness : float = 0.2
Property Value
Remarks
global_canvas_transform
The global canvas transform of the viewport. The canvas transform is relative to this.
var global_canvas_transform : Transform2D
Property Value
Remarks
- void set_global_canvas_transform(Transform2D value)
- Transform2D get_global_canvas_transform
gui_disable_input
If true
, the viewport will not receive input events.
var gui_disable_input : bool = false
Property Value
Remarks
gui_embed_subwindows
If true
, sub-windows (popups and dialogs) will be embedded inside application window as control-like nodes. If false
, they will appear as separate windows handled by the operating system.
var gui_embed_subwindows : bool = false
Property Value
Remarks
gui_snap_controls_to_pixels
If true
, the GUI controls on the viewport will lay pixel perfectly.
var gui_snap_controls_to_pixels : bool = true
Property Value
Remarks
handle_input_locally
If true
, this viewport will mark incoming input events as handled by itself. If false
, this is instead done by the first parent viewport that is set to handle input locally.
A SubViewportContainer will automatically set this property to false
for the Viewport contained inside of it.
See also set_input_as_handled and is_input_handled.
var handle_input_locally : bool = true
Property Value
Remarks
mesh_lod_threshold
The automatic LOD bias to use for meshes rendered within the Viewport (this is analogous to mesh_lod_threshold). Higher values will use less detailed versions of meshes that have LOD variations generated. If set to 0.0
, automatic LOD is disabled. Increase mesh_lod_threshold to improve performance at the cost of geometry detail.
To control this property on the root viewport, set the rendering/mesh_lod/lod_change/threshold_pixels project setting.
Note: mesh_lod_threshold does not affect GeometryInstance3D visibility ranges (also known as "manual" LOD or hierarchical LOD).
var mesh_lod_threshold : float = 1.0
Property Value
Remarks
msaa_2d
The multisample antialiasing mode for 2D/Canvas rendering. A higher number results in smoother edges at the cost of significantly worse performance. A value of Viewport.MSAA_2X or Viewport.MSAA_4X is best unless targeting very high-end systems. This has no effect on shader-induced aliasing or texture aliasing.
See also rendering/anti_aliasing/quality/msaa_2d and RenderingServer.viewport_set_msaa_2d.
var msaa_2d : int = 0
Property Value
Remarks
msaa_3d
The multisample antialiasing mode for 3D rendering. A higher number results in smoother edges at the cost of significantly worse performance. A value of Viewport.MSAA_2X or Viewport.MSAA_4X is best unless targeting very high-end systems. See also bilinear scaling 3D scaling_3d_mode for supersampling, which provides higher quality but is much more expensive. This has no effect on shader-induced aliasing or texture aliasing.
See also rendering/anti_aliasing/quality/msaa_3d and RenderingServer.viewport_set_msaa_3d.
var msaa_3d : int = 0
Property Value
Remarks
own_world_3d
var own_world_3d : bool = false
Property Value
Remarks
physics_object_picking
If true
, the objects rendered by viewport become subjects of mouse picking process.
Note: The number of simultaneously pickable objects is limited to 64 and they are selected in a non-deterministic order, which can be different in each picking process.
var physics_object_picking : bool = false
Property Value
Remarks
physics_object_picking_first_only
If true
, the input_event signal will only be sent to one physics object in the mouse picking process. If you want to get the top object only, you must also enable physics_object_picking_sort.
If false
, an input_event signal will be sent to all physics objects in the mouse picking process.
This applies to 2D CanvasItem object picking only.
var physics_object_picking_first_only : bool = false
Property Value
Remarks
physics_object_picking_sort
If true
, objects receive mouse picking events sorted primarily by their z_index and secondarily by their position in the scene tree. If false
, the order is undetermined.
Note: This setting is disabled by default because of its potential expensive computational cost.
Note: Sorting happens after selecting the pickable objects. Because of the limitation of 64 simultaneously pickable objects, it is not guaranteed that the object with the highest z_index receives the picking event.
var physics_object_picking_sort : bool = false
Property Value
Remarks
positional_shadow_atlas_16_bits
Use 16 bits for the omni/spot shadow depth map. Enabling this results in shadows having less precision and may result in shadow acne, but can lead to performance improvements on some devices.
var positional_shadow_atlas_16_bits : bool = true
Property Value
Remarks
positional_shadow_atlas_quad_0
The subdivision amount of the first quadrant on the shadow atlas.
var positional_shadow_atlas_quad_0 : int = 2
Property Value
Remarks
positional_shadow_atlas_quad_1
The subdivision amount of the second quadrant on the shadow atlas.
var positional_shadow_atlas_quad_1 : int = 2
Property Value
Remarks
positional_shadow_atlas_quad_2
The subdivision amount of the third quadrant on the shadow atlas.
var positional_shadow_atlas_quad_2 : int = 3
Property Value
Remarks
positional_shadow_atlas_quad_3
The subdivision amount of the fourth quadrant on the shadow atlas.
var positional_shadow_atlas_quad_3 : int = 4
Property Value
Remarks
positional_shadow_atlas_size
The shadow atlas' resolution (used for omni and spot lights). The value is rounded up to the nearest power of 2.
Note: If this is set to 0
, no positional shadows will be visible at all. This can improve performance significantly on low-end systems by reducing both the CPU and GPU load (as fewer draw calls are needed to draw the scene without shadows).
var positional_shadow_atlas_size : int = 2048
Property Value
Remarks
scaling_3d_mode
Sets scaling 3D mode. Bilinear scaling renders at different resolution to either undersample or supersample the viewport. FidelityFX Super Resolution 1.0, abbreviated to FSR, is an upscaling technology that produces high quality images at fast framerates by using a spatially aware upscaling algorithm. FSR is slightly more expensive than bilinear, but it produces significantly higher image quality. FSR should be used where possible.
To control this property on the root viewport, set the rendering/scaling_3d/mode project setting.
var scaling_3d_mode : int = 0
Property Value
Remarks
scaling_3d_scale
Scales the 3D render buffer based on the viewport size uses an image filter specified in rendering/scaling_3d/mode to scale the output image to the full viewport size. Values lower than 1.0
can be used to speed up 3D rendering at the cost of quality (undersampling). Values greater than 1.0
are only valid for bilinear mode and can be used to improve 3D rendering quality at a high performance cost (supersampling). See also rendering/anti_aliasing/quality/msaa_3d for multi-sample antialiasing, which is significantly cheaper but only smooths the edges of polygons.
When using FSR upscaling, AMD recommends exposing the following values as preset options to users "Ultra Quality: 0.77", "Quality: 0.67", "Balanced: 0.59", "Performance: 0.5" instead of exposing the entire scale.
To control this property on the root viewport, set the rendering/scaling_3d/scale project setting.
var scaling_3d_scale : float = 1.0
Property Value
Remarks
screen_space_aa
Sets the screen-space antialiasing method used. Screen-space antialiasing works by selectively blurring edges in a post-process shader. It differs from MSAA which takes multiple coverage samples while rendering objects. Screen-space AA methods are typically faster than MSAA and will smooth out specular aliasing, but tend to make scenes appear blurry.
See also rendering/anti_aliasing/quality/screen_space_aa and RenderingServer.viewport_set_screen_space_aa.
var screen_space_aa : int = 0
Property Value
Remarks
sdf_oversize
Controls how much of the original viewport's size should be covered by the 2D signed distance field. This SDF can be sampled in CanvasItem shaders and is also used for GPUParticles2D collision. Higher values allow portions of occluders located outside the viewport to still be taken into account in the generated signed distance field, at the cost of performance. If you notice particles falling through LightOccluder2Ds as the occluders leave the viewport, increase this setting.
The percentage is added on each axis and on both sides. For example, with the default Viewport.SDF_OVERSIZE_120_PERCENT, the signed distance field will cover 20% of the viewport's size outside the viewport on each side (top, right, bottom, left).
var sdf_oversize : int = 1
Property Value
Remarks
sdf_scale
The resolution scale to use for the 2D signed distance field. Higher values lead to a more precise and more stable signed distance field as the camera moves, at the cost of performance.
var sdf_scale : int = 1
Property Value
Remarks
snap_2d_transforms_to_pixel
If true
, CanvasItem nodes will internally snap to full pixels. Their position can still be sub-pixel, but the decimals will not have effect. This can lead to a crisper appearance at the cost of less smooth movement, especially when Camera2D smoothing is enabled.
var snap_2d_transforms_to_pixel : bool = false
Property Value
Remarks
snap_2d_vertices_to_pixel
If true
, vertices of CanvasItem nodes will snap to full pixels. Only affects the final vertex positions, not the transforms. This can lead to a crisper appearance at the cost of less smooth movement, especially when Camera2D smoothing is enabled.
var snap_2d_vertices_to_pixel : bool = false
Property Value
Remarks
texture_mipmap_bias
Affects the final texture sharpness by reading from a lower or higher mipmap (also called "texture LOD bias"). Negative values make mipmapped textures sharper but grainier when viewed at a distance, while positive values make mipmapped textures blurrier (even when up close).
Enabling temporal antialiasing (use_taa) will automatically apply a -0.5
offset to this value, while enabling FXAA (screen_space_aa) will automatically apply a -0.25
offset to this value. If both TAA and FXAA are enabled at the same time, an offset of -0.75
is applied to this value.
Note: If scaling_3d_scale is lower than 1.0
(exclusive), texture_mipmap_bias is used to adjust the automatic mipmap bias which is calculated internally based on the scale factor. The formula for this is log2(scaling_3d_scale) + mipmap_bias
.
To control this property on the root viewport, set the rendering/textures/default_filters/texture_mipmap_bias project setting.
var texture_mipmap_bias : float = 0.0
Property Value
Remarks
transparent_bg
If true
, the viewport should render its background as transparent.
var transparent_bg : bool = false
Property Value
Remarks
use_debanding
If true
, uses a fast post-processing filter to make banding significantly less visible in 3D. 2D rendering is not affected by debanding unless the background_mode is Environment.BG_CANVAS.
In some cases, debanding may introduce a slightly noticeable dithering pattern. It's recommended to enable debanding only when actually needed since the dithering pattern will make lossless-compressed screenshots larger.
See also rendering/anti_aliasing/quality/use_debanding and RenderingServer.viewport_set_use_debanding.
var use_debanding : bool = false
Property Value
Remarks
use_hdr_2d
If true
, 2D rendering will use an high dynamic range (HDR) format framebuffer matching the bit depth of the 3D framebuffer. When using the Forward+ renderer this will be an RGBA16
framebuffer, while when using the Mobile renderer it will be an RGB10_A2
framebuffer. Additionally, 2D rendering will take place in linear color space and will be converted to sRGB space immediately before blitting to the screen (if the Viewport is attached to the screen). Practically speaking, this means that the end result of the Viewport will not be clamped into the 0-1
range and can be used in 3D rendering without color space adjustments. This allows 2D rendering to take advantage of effects requiring high dynamic range (e.g. 2D glow) as well as substantially improves the appearance of effects requiring highly detailed gradients.
Note: This setting will have no effect when using the Compatibility renderer, which always renders in low dynamic range for performance reasons.
var use_hdr_2d : bool = false
Property Value
Remarks
use_occlusion_culling
If true
, OccluderInstance3D nodes will be usable for occlusion culling in 3D for this viewport. For the root viewport, rendering/occlusion_culling/use_occlusion_culling must be set to true
instead.
Note: Enabling occlusion culling has a cost on the CPU. Only enable occlusion culling if you actually plan to use it, and think whether your scene can actually benefit from occlusion culling. Large, open scenes with few or no objects blocking the view will generally not benefit much from occlusion culling. Large open scenes generally benefit more from mesh LOD and visibility ranges (visibility_range_begin and visibility_range_end) compared to occlusion culling.
Note: Due to memory constraints, occlusion culling is not supported by default in Web export templates. It can be enabled by compiling custom Web export templates with module_raycast_enabled=yes
.
var use_occlusion_culling : bool = false
Property Value
Remarks
use_taa
Enables temporal antialiasing for this viewport. TAA works by jittering the camera and accumulating the images of the last rendered frames, motion vector rendering is used to account for camera and object motion.
Note: The implementation is not complete yet, some visual instances such as particles and skinned meshes may show artifacts.
See also rendering/anti_aliasing/quality/use_taa and RenderingServer.viewport_set_use_taa.
var use_taa : bool = false
Property Value
Remarks
use_xr
If true
, the viewport will use the primary XR interface to render XR output. When applicable this can result in a stereoscopic image and the resulting render being output to a headset.
var use_xr : bool = false
Property Value
Remarks
vrs_mode
The Variable Rate Shading (VRS) mode that is used for this viewport. Note, if hardware does not support VRS this property is ignored.
var vrs_mode : int = 0
Property Value
Remarks
vrs_texture
Texture to use when vrs_mode is set to Viewport.VRS_TEXTURE.
The texture must use a lossless compression format so that colors can be matched precisely. The following VRS densities are mapped to various colors, with brighter colors representing a lower level of shading precision:
- 1×1 = rgb(0, 0, 0) - #000000
- 1×2 = rgb(0, 85, 0) - #005500
- 2×1 = rgb(85, 0, 0) - #550000
- 2×2 = rgb(85, 85, 0) - #555500
- 2×4 = rgb(85, 170, 0) - #55aa00
- 4×2 = rgb(170, 85, 0) - #aa5500
- 4×4 = rgb(170, 170, 0) - #aaaa00
- 4×8 = rgb(170, 255, 0) - #aaff00 - Not supported on most hardware
- 8×4 = rgb(255, 170, 0) - #ffaa00 - Not supported on most hardware
- 8×8 = rgb(255, 255, 0) - #ffff00 - Not supported on most hardware
var vrs_texture : Texture2D
Property Value
Remarks
vrs_update_mode
Sets the update mode for Variable Rate Shading (VRS) for the viewport. VRS requires the input texture to be converted to the format usable by the VRS method supported by the hardware. The update mode defines how often this happens. If the GPU does not support VRS, or VRS is not enabled, this property is ignored.
var vrs_update_mode : int = 1
Property Value
Remarks
world_2d
The custom World2D which can be used as 2D environment source.
var world_2d : World2D
Property Value
Remarks
world_3d
The custom World3D which can be used as 3D environment source.
var world_3d : World3D
Property Value
Remarks
Methods
find_world_2d
Qualifiers: const
Returns the first valid World2D for this viewport, searching the world_2d property of itself and any Viewport ancestor.
World2D find_world_2d
find_world_3d
Qualifiers: const
Returns the first valid World3D for this viewport, searching the world_3d property of itself and any Viewport ancestor.
World3D find_world_3d
get_audio_listener_2d
Qualifiers: const
Returns the currently active 2D audio listener. Returns null
if there are no active 2D audio listeners, in which case the active 2D camera will be treated as listener.
AudioListener2D get_audio_listener_2d
get_audio_listener_3d
Qualifiers: const
Returns the currently active 3D audio listener. Returns null
if there are no active 3D audio listeners, in which case the active 3D camera will be treated as listener.
AudioListener3D get_audio_listener_3d
get_camera_2d
Qualifiers: const
Returns the currently active 2D camera. Returns null
if there are no active cameras.
Camera2D get_camera_2d
get_camera_3d
Qualifiers: const
Returns the currently active 3D camera.
Camera3D get_camera_3d
get_canvas_cull_mask_bit(int)
Qualifiers: const
Returns an individual bit on the rendering layer mask.
bool get_canvas_cull_mask_bit(int layer)
Parameters
layer
int
get_embedded_subwindows
Qualifiers: const
Returns a list of the visible embedded Windows inside the viewport.
Note: Windows inside other viewports will not be listed.
Window[] get_embedded_subwindows
get_final_transform
Qualifiers: const
Returns the transform from the viewport's coordinate system to the embedder's coordinate system.
Transform2D get_final_transform
get_mouse_position
Qualifiers: const
Returns the mouse's position in this Viewport using the coordinate system of this Viewport.
Vector2 get_mouse_position
get_positional_shadow_atlas_quadrant_subdiv(int)
Qualifiers: const
Returns the positional shadow atlas quadrant subdivision of the specified quadrant.
int get_positional_shadow_atlas_quadrant_subdiv(int quadrant)
Parameters
quadrant
int
get_render_info(int, int)
Returns rendering statistics of the given type. See RenderInfoType and RenderInfo for options.
int get_render_info(int type, int info)
Parameters
get_screen_transform
Qualifiers: const
Returns the transform from the Viewport's coordinates to the screen coordinates of the containing window manager window.
Transform2D get_screen_transform
get_stretch_transform
Qualifiers: const
Returns the automatically computed 2D stretch transform, taking the Viewport's stretch settings into account. The final value is multiplied by content_scale_factor, but only for the root viewport. If this method is called on a SubViewport (e.g., in a scene tree with SubViewportContainer and SubViewport), the scale factor of the root window will not be applied. Using get_scale on the returned value, this can be used to compensate for scaling when zooming a Camera2D node, or to scale down a TextureRect to be pixel-perfect regardless of the automatically computed scale factor.
Note: Due to how pixel scaling works, the returned transform's X and Y scale may differ slightly, even when content_scale_aspect is set to a mode that preserves the pixels' aspect ratio. If content_scale_aspect is Window.CONTENT_SCALE_ASPECT_IGNORE, the X and Y scale may differ significantly.
Transform2D get_stretch_transform
get_texture
Qualifiers: const
Returns the viewport's texture.
Note: When trying to store the current texture (e.g. in a file), it might be completely black or outdated if used too early, especially when used in e.g. _ready. To make sure the texture you get is correct, you can await frame_post_draw signal.
func _ready():
await RenderingServer.frame_post_draw
$Viewport.get_texture().get_image().save_png("user://Screenshot.png")
Note: When use_hdr_2d is true
the returned texture will be an HDR image encoded in linear space.
ViewportTexture get_texture
get_viewport_rid
Qualifiers: const
Returns the viewport's RID from the RenderingServer.
RID get_viewport_rid
get_visible_rect
Qualifiers: const
Returns the visible rectangle in global screen coordinates.
Rect2 get_visible_rect
gui_cancel_drag
Cancels the drag operation that was previously started through Control._get_drag_data or forced with Control.force_drag.
void gui_cancel_drag
gui_get_drag_data
Qualifiers: const
Returns the drag data from the GUI, that was previously returned by Control._get_drag_data.
Variant gui_get_drag_data
gui_get_focus_owner
Qualifiers: const
Returns the currently focused Control within this viewport. If no Control is focused, returns null
.
Control gui_get_focus_owner
gui_get_hovered_control
Qualifiers: const
Returns the Control that the mouse is currently hovering over in this viewport. If no Control has the cursor, returns null
.
Typically the leaf Control node or deepest level of the subtree which claims hover. This is very useful when used together with Node.is_ancestor_of to find if the mouse is within a control tree.
Control gui_get_hovered_control
gui_is_drag_successful
Qualifiers: const
Returns true
if the drag operation is successful.
bool gui_is_drag_successful
gui_is_dragging
Qualifiers: const
Returns true
if a drag operation is currently ongoing and where the drop action could happen in this viewport.
Alternative to NOTIFICATION_DRAG_BEGIN and NOTIFICATION_DRAG_END when you prefer polling the value.
bool gui_is_dragging
gui_release_focus
Removes the focus from the currently focused Control within this viewport. If no Control has the focus, does nothing.
void gui_release_focus
is_input_handled
Qualifiers: const
Returns whether the current InputEvent has been handled. Input events are not handled until set_input_as_handled has been called during the lifetime of an InputEvent.
This is usually done as part of input handling methods like Node._input, Control._gui_input or others, as well as in corresponding signal handlers.
If handle_input_locally is set to false
, this method will try finding the first parent viewport that is set to handle input locally, and return its value for is_input_handled instead.
bool is_input_handled
notify_mouse_entered
Inform the Viewport that the mouse has entered its area. Use this function before sending an InputEventMouseButton or InputEventMouseMotion to the Viewport with Viewport.push_input. See also notify_mouse_exited.
Note: In most cases, it is not necessary to call this function because SubViewport nodes that are children of SubViewportContainer are notified automatically. This is only necessary when interacting with viewports in non-default ways, for example as textures in TextureRect or with an Area3D that forwards input events.
void notify_mouse_entered
notify_mouse_exited
Inform the Viewport that the mouse has left its area. Use this function when the node that displays the viewport notices the mouse has left the area of the displayed viewport. See also notify_mouse_entered.
Note: In most cases, it is not necessary to call this function because SubViewport nodes that are children of SubViewportContainer are notified automatically. This is only necessary when interacting with viewports in non-default ways, for example as textures in TextureRect or with an Area3D that forwards input events.
void notify_mouse_exited
push_input(InputEvent, bool)
Triggers the given event
in this Viewport. This can be used to pass an InputEvent between viewports, or to locally apply inputs that were sent over the network or saved to a file.
If in_local_coords
is false
, the event's position is in the embedder's coordinates and will be converted to viewport coordinates. If in_local_coords
is true
, the event's position is in viewport coordinates.
While this method serves a similar purpose as Input.parse_input_event, it does not remap the specified event
based on project settings like input_devices/pointing/emulate_touch_from_mouse.
Calling this method will propagate calls to child nodes for following methods in the given order:
Node._input
Control._gui_input for Control nodes
Node._shortcut_input
Node._unhandled_key_input
Node._unhandled_input
If an earlier method marks the input as handled via set_input_as_handled, any later method in this list will not be called.
If none of the methods handle the event and physics_object_picking is true
, the event is used for physics object picking.
void push_input(InputEvent event, bool in_local_coords)
Parameters
event
InputEventin_local_coords
bool
push_text_input(String)
Helper method which calls the set_text()
method on the currently focused Control, provided that it is defined (e.g. if the focused Control is Button or LineEdit).
void push_text_input(String text)
Parameters
text
String
push_unhandled_input(InputEvent, bool)
Triggers the given event
in this Viewport. This can be used to pass an InputEvent between viewports, or to locally apply inputs that were sent over the network or saved to a file.
If in_local_coords
is false
, the event's position is in the embedder's coordinates and will be converted to viewport coordinates. If in_local_coords
is true
, the event's position is in viewport coordinates.
Calling this method will propagate calls to child nodes for following methods in the given order:
Node._shortcut_input
Node._unhandled_key_input
Node._unhandled_input
If an earlier method marks the input as handled via set_input_as_handled, any later method in this list will not be called.
If none of the methods handle the event and physics_object_picking is true
, the event is used for physics object picking.
Note: This method doesn't propagate input events to embedded Windows or SubViewports.
void push_unhandled_input(InputEvent event, bool in_local_coords)
Parameters
event
InputEventin_local_coords
bool
set_canvas_cull_mask_bit(int, bool)
Set/clear individual bits on the rendering layer mask. This simplifies editing this Viewport's layers.
void set_canvas_cull_mask_bit(int layer, bool enable)
Parameters
set_input_as_handled
Stops the input from propagating further down the SceneTree.
Note: This does not affect the methods in Input, only the way events are propagated.
void set_input_as_handled
set_positional_shadow_atlas_quadrant_subdiv(int, int)
Sets the number of subdivisions to use in the specified quadrant. A higher number of subdivisions allows you to have more shadows in the scene at once, but reduces the quality of the shadows. A good practice is to have quadrants with a varying number of subdivisions and to have as few subdivisions as possible.
void set_positional_shadow_atlas_quadrant_subdiv(int quadrant, int subdiv)
Parameters
update_mouse_cursor_state
Force instantly updating the display based on the current mouse cursor position. This includes updating the mouse cursor shape and sending necessary mouse_entered, mouse_entered, mouse_entered and mouse_entered signals and their respective mouse_exited
counterparts.
void update_mouse_cursor_state
warp_mouse(Vector2)
Moves the mouse pointer to the specified position in this Viewport using the coordinate system of this Viewport.
Note: Viewport.warp_mouse is only supported on Windows, macOS and Linux. It has no effect on Android, iOS and Web.
void warp_mouse(Vector2 position)
Parameters
position
Vector2
Events
gui_focus_changed(Control)
Emitted when a Control node grabs keyboard focus.
Note: A Control node losing focus doesn't cause this signal to be emitted.
signal gui_focus_changed(Control node)
Parameters
node
Control
size_changed
Emitted when the size of the viewport is changed, whether by resizing of window, or some other means.
signal size_changed