Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
Viewport
被繼承: SubViewport, Window
視口的抽象基底類別。對繪圖以及與遊戲世界的互動進行了封裝。
說明
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.
教學
屬性
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
physics_interpolation_mode |
|
|
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
方法
訊號
gui_focus_changed(node: Control) 🔗
Emitted when a Control node grabs keyboard focus.
Note: A Control node losing focus doesn't cause this signal to be emitted.
size_changed() 🔗
當視口的大小被改變時發出,無論是通過調整視窗大小,還是通過其他方式改變的大小。
列舉
enum PositionalShadowAtlasQuadrantSubdiv: 🔗
PositionalShadowAtlasQuadrantSubdiv SHADOW_ATLAS_QUADRANT_SUBDIV_DISABLED = 0
不使用該象限。
PositionalShadowAtlasQuadrantSubdiv SHADOW_ATLAS_QUADRANT_SUBDIV_1 = 1
該象限僅由一張陰影貼圖使用。
PositionalShadowAtlasQuadrantSubdiv SHADOW_ATLAS_QUADRANT_SUBDIV_4 = 2
該象限將被分為 4 份,最多被 4 張陰影貼圖使用。
PositionalShadowAtlasQuadrantSubdiv SHADOW_ATLAS_QUADRANT_SUBDIV_16 = 3
該象限將被分為 16 份,最多被 16 張陰影貼圖使用。
PositionalShadowAtlasQuadrantSubdiv SHADOW_ATLAS_QUADRANT_SUBDIV_64 = 4
該象限將被分為 64 份,最多被 64 張陰影貼圖使用。
PositionalShadowAtlasQuadrantSubdiv SHADOW_ATLAS_QUADRANT_SUBDIV_256 = 5
該象限將被分為 256 份,最多被 256 張陰影貼圖使用。除非 positional_shadow_atlas_size 非常高,否則該象限中的陰影解析度將非常低。
PositionalShadowAtlasQuadrantSubdiv SHADOW_ATLAS_QUADRANT_SUBDIV_1024 = 6
該象限將被分為 1024 份,最多被 1024 張陰影貼圖使用。除非 positional_shadow_atlas_size 非常高,否則該象限中的陰影解析度將非常低。
PositionalShadowAtlasQuadrantSubdiv SHADOW_ATLAS_QUADRANT_SUBDIV_MAX = 7
代表 PositionalShadowAtlasQuadrantSubdiv 列舉的大小。
enum Scaling3DMode: 🔗
Scaling3DMode SCALING_3D_MODE_BILINEAR = 0
對該視口的 3D 緩衝區使用雙線性縮放。縮放的程度可以使用 scaling_3d_scale 設定。小於 1.0 的值會產生欠取樣的效果,大於 1.0 會產生超取樣的效果。值為 1.0 時禁用縮放。
Scaling3DMode SCALING_3D_MODE_FSR = 1
Use AMD FidelityFX Super Resolution 1.0 upscaling for the viewport's 3D buffer. The amount of scaling can be set using scaling_3d_scale. Values less than 1.0 will result in the viewport being upscaled using FSR. Values greater than 1.0 are not supported and bilinear downsampling will be used instead. A value of 1.0 disables scaling.
Scaling3DMode SCALING_3D_MODE_FSR2 = 2
Use AMD FidelityFX Super Resolution 2.2 upscaling for the viewport's 3D buffer. The amount of scaling can be set using scaling_3d_scale. Values less than 1.0 will result in the viewport being upscaled using FSR2. Values greater than 1.0 are not supported and bilinear downsampling will be used instead. A value of 1.0 will use FSR2 at native resolution as a TAA solution.
Scaling3DMode SCALING_3D_MODE_METALFX_SPATIAL = 3
Use the MetalFX spatial upscaler for the viewport's 3D buffer.
The amount of scaling can be set using scaling_3d_scale.
Values less than 1.0 will result in the viewport being upscaled using MetalFX. Values greater than 1.0 are not supported and bilinear downsampling will be used instead. A value of 1.0 disables scaling.
More information: MetalFX.
Note: Only supported when the Metal rendering driver is in use, which limits this scaling mode to macOS and iOS.
Scaling3DMode SCALING_3D_MODE_METALFX_TEMPORAL = 4
Use the MetalFX temporal upscaler for the viewport's 3D buffer.
The amount of scaling can be set using scaling_3d_scale. To determine the minimum input scale, use the RenderingDevice.limit_get() method with RenderingDevice.LIMIT_METALFX_TEMPORAL_SCALER_MIN_SCALE.
Values less than 1.0 will result in the viewport being upscaled using MetalFX. Values greater than 1.0 are not supported and bilinear downsampling will be used instead. A value of 1.0 will use MetalFX at native resolution as a TAA solution.
More information: MetalFX.
Note: Only supported when the Metal rendering driver is in use, which limits this scaling mode to macOS and iOS.
Scaling3DMode SCALING_3D_MODE_NEAREST = 5
Use nearest-neighbor filtering for the viewport's 3D buffer. This looks crisper than SCALING_3D_MODE_BILINEAR and has no additional rendering cost. The amount of scaling can be set using scaling_3d_scale. Values greater than 1.0 are not supported and bilinear downsampling will be used instead. A value of 1.0 disables scaling.
Note: When using the Nearest scaling mode, to avoid uneven pixel scaling, it's highly recommended to use a value equal to an integer divisor with a dividend of 1. For example, it's best to use a scale of 0.5 (1/2), 0.3333 (1/3), 0.25 (1/4), 0.2 (1/5), and so on.
Scaling3DMode SCALING_3D_MODE_MAX = 6
代表 Scaling3DMode 列舉的大小。
enum MSAA: 🔗
MSAA MSAA_DISABLED = 0
禁用多重取樣抗鋸齒模式。這是預設值,也是最快的設定。
MSAA MSAA_2X = 1
使用 2 倍多重取樣抗鋸齒。性能成本中等。有助於顯著減少鋸齒,但 4× MSAA 看起來仍然要好得多。
MSAA MSAA_4X = 2
使用 4 倍多重取樣抗鋸齒。性能成本顯著,通常是性能和品質之間的良好折衷。
MSAA MSAA_8X = 3
使用 8 倍多重取樣抗鋸齒。性能成本極高。在實際遊戲條件下,4× 和 8× MSAA 之間的差異可能並不總是可見的。可能在低端和較舊的硬體上不受支援。
MSAA MSAA_MAX = 4
代表 MSAA 列舉的大小。
enum AnisotropicFiltering: 🔗
AnisotropicFiltering ANISOTROPY_DISABLED = 0
Anisotropic filtering is disabled.
AnisotropicFiltering ANISOTROPY_2X = 1
Use 2× anisotropic filtering.
AnisotropicFiltering ANISOTROPY_4X = 2
Use 4× anisotropic filtering. This is the default value.
AnisotropicFiltering ANISOTROPY_8X = 3
Use 8× anisotropic filtering.
AnisotropicFiltering ANISOTROPY_16X = 4
Use 16× anisotropic filtering.
AnisotropicFiltering ANISOTROPY_MAX = 5
Represents the size of the AnisotropicFiltering enum.
enum ScreenSpaceAA: 🔗
ScreenSpaceAA SCREEN_SPACE_AA_DISABLED = 0
不要在全屏後處理中執行抗鋸齒。
ScreenSpaceAA SCREEN_SPACE_AA_FXAA = 1
使用快速近似抗鋸齒(Fast Approximate Anti-Aliasing)。FXAA 是一種流行的螢幕空間抗鋸齒方法,速度很快,但會讓圖像變模糊,使用較低解析度時尤為顯著。1440p 和 4K 等較高解析度下效果仍然不錯。
ScreenSpaceAA SCREEN_SPACE_AA_SMAA = 2
Use subpixel morphological antialiasing. SMAA may produce clearer results than FXAA, but at a slightly higher performance cost.
ScreenSpaceAA SCREEN_SPACE_AA_MAX = 3
代表 ScreenSpaceAA 列舉的大小。
enum RenderInfo: 🔗
RenderInfo RENDER_INFO_OBJECTS_IN_FRAME = 0
影格中物件的數量。
RenderInfo RENDER_INFO_PRIMITIVES_IN_FRAME = 1
影格中的頂點數量。
RenderInfo RENDER_INFO_DRAW_CALLS_IN_FRAME = 2
影格中的繪製呼叫量。
RenderInfo RENDER_INFO_MAX = 3
代表 RenderInfo 列舉的大小。
enum RenderInfoType: 🔗
RenderInfoType RENDER_INFO_TYPE_VISIBLE = 0
可見算繪階段(不含陰影)。
RenderInfoType RENDER_INFO_TYPE_SHADOW = 1
陰影算繪階段。根據開啟了陰影的燈光數以及方向陰影的拆分數,同一個物件可能會算繪多次。
RenderInfoType RENDER_INFO_TYPE_CANVAS = 2
Canvas item rendering. This includes all 2D rendering.
RenderInfoType RENDER_INFO_TYPE_MAX = 3
Represents the size of the RenderInfoType enum.
enum DebugDraw: 🔗
DebugDraw DEBUG_DRAW_DISABLED = 0
物件正常顯示。
DebugDraw DEBUG_DRAW_UNSHADED = 1
顯示的物件沒有光照資訊。
DebugDraw DEBUG_DRAW_LIGHTING = 2
Objects are displayed without textures and only with lighting information.
Note: When using this debug draw mode, custom shaders are ignored since all materials in the scene temporarily use a debug material. This means the result from custom shader functions (such as vertex displacement) won't be visible anymore when using this debug draw mode.
DebugDraw DEBUG_DRAW_OVERDRAW = 3
Objects are displayed semi-transparent with additive blending so you can see where they are drawing over top of one another. A higher overdraw means you are wasting performance on drawing pixels that are being hidden behind others.
Note: When using this debug draw mode, custom shaders are ignored since all materials in the scene temporarily use a debug material. This means the result from custom shader functions (such as vertex displacement) won't be visible anymore when using this debug draw mode.
DebugDraw DEBUG_DRAW_WIREFRAME = 4
Objects are displayed as wireframe models.
Note: RenderingServer.set_debug_generate_wireframes() must be called before loading any meshes for wireframes to be visible when using the Compatibility renderer.
Note: In the Compatibility renderer, backfaces are always visible when using wireframe rendering. In the Forward+ and Mobile renderers, wireframes follow the material's backface culling properties instead.
DebugDraw DEBUG_DRAW_NORMAL_BUFFER = 5
Objects are displayed without lighting information and their textures replaced by normal mapping.
Note: Only supported when using the Forward+ rendering method.
DebugDraw DEBUG_DRAW_VOXEL_GI_ALBEDO = 6
Objects are displayed with only the albedo value from VoxelGIs. Requires at least one visible VoxelGI node that has been baked to have a visible effect.
Note: Only supported when using the Forward+ rendering method.
DebugDraw DEBUG_DRAW_VOXEL_GI_LIGHTING = 7
Objects are displayed with only the lighting value from VoxelGIs. Requires at least one visible VoxelGI node that has been baked to have a visible effect.
Note: Only supported when using the Forward+ rendering method.
DebugDraw DEBUG_DRAW_VOXEL_GI_EMISSION = 8
Objects are displayed with only the emission color from VoxelGIs. Requires at least one visible VoxelGI node that has been baked to have a visible effect.
Note: Only supported when using the Forward+ rendering method.
DebugDraw DEBUG_DRAW_SHADOW_ATLAS = 9
在 Viewport 的左上象限中繪製儲存來自 OmniLight3D 和 SpotLight3D 的陰影的陰影合集。
DebugDraw DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS = 10
在 Viewport 的左上象限中繪製儲存來自 DirectionalLight3D 的陰影的陰影圖集。
DebugDraw DEBUG_DRAW_SCENE_LUMINANCE = 11
Draws the scene luminance buffer (if available) in the upper left quadrant of the Viewport.
Note: Only supported when using the Forward+ or Mobile rendering methods.
DebugDraw DEBUG_DRAW_SSAO = 12
Draws the screen-space ambient occlusion texture instead of the scene so that you can clearly see how it is affecting objects. In order for this display mode to work, you must have Environment.ssao_enabled set in your WorldEnvironment.
Note: Only supported when using the Forward+ rendering method.
DebugDraw DEBUG_DRAW_SSIL = 13
Draws the screen-space indirect lighting texture instead of the scene so that you can clearly see how it is affecting objects. In order for this display mode to work, you must have Environment.ssil_enabled set in your WorldEnvironment.
Note: Only supported when using the Forward+ rendering method.
DebugDraw DEBUG_DRAW_PSSM_SPLITS = 14
Colors each PSSM split for the DirectionalLight3Ds in the scene a different color so you can see where the splits are. In order (from closest to furthest from the camera), they are colored red, green, blue, and yellow.
Note: When using this debug draw mode, custom shaders are ignored since all materials in the scene temporarily use a debug material. This means the result from custom shader functions (such as vertex displacement) won't be visible anymore when using this debug draw mode.
Note: Only supported when using the Forward+ or Mobile rendering methods.
DebugDraw DEBUG_DRAW_DECAL_ATLAS = 15
Draws the decal atlas used by Decals and light projector textures in the upper left quadrant of the Viewport.
Note: Only supported when using the Forward+ or Mobile rendering methods.
DebugDraw DEBUG_DRAW_SDFGI = 16
Draws the cascades used to render signed distance field global illumination (SDFGI).
Does nothing if the current environment's Environment.sdfgi_enabled is false.
Note: Only supported when using the Forward+ rendering method.
DebugDraw DEBUG_DRAW_SDFGI_PROBES = 17
Draws the probes used for signed distance field global illumination (SDFGI).
When in the editor, left-clicking a probe will display additional bright dots that show its occlusion information. A white dot means the light is not occluded at all at the dot's position, while a red dot means the light is fully occluded. Intermediate values are possible.
Does nothing if the current environment's Environment.sdfgi_enabled is false.
Note: Only supported when using the Forward+ rendering method.
DebugDraw DEBUG_DRAW_GI_BUFFER = 18
Draws the buffer used for global illumination from VoxelGI or SDFGI. Requires VoxelGI (at least one visible baked VoxelGI node) or SDFGI (Environment.sdfgi_enabled) to be enabled to have a visible effect.
Note: Only supported when using the Forward+ rendering method.
DebugDraw DEBUG_DRAW_DISABLE_LOD = 19
Draws all of the objects at their highest polycount regardless of their distance from the camera. No low level of detail (LOD) is applied.
DebugDraw DEBUG_DRAW_CLUSTER_OMNI_LIGHTS = 20
Draws the cluster used by OmniLight3D nodes to optimize light rendering.
Note: Only supported when using the Forward+ rendering method.
DebugDraw DEBUG_DRAW_CLUSTER_SPOT_LIGHTS = 21
Draws the cluster used by SpotLight3D nodes to optimize light rendering.
Note: Only supported when using the Forward+ rendering method.
DebugDraw DEBUG_DRAW_CLUSTER_DECALS = 22
Draws the cluster used by Decal nodes to optimize decal rendering.
Note: Only supported when using the Forward+ rendering method.
DebugDraw DEBUG_DRAW_CLUSTER_REFLECTION_PROBES = 23
Draws the cluster used by ReflectionProbe nodes to optimize reflection probes.
Note: Only supported when using the Forward+ rendering method.
DebugDraw DEBUG_DRAW_OCCLUDERS = 24
Draws the buffer used for occlusion culling.
Note: Only supported when using the Forward+ or Mobile rendering methods.
DebugDraw DEBUG_DRAW_MOTION_VECTORS = 25
Draws vector lines over the viewport to indicate the movement of pixels between frames.
Note: Only supported when using the Forward+ rendering method.
DebugDraw DEBUG_DRAW_INTERNAL_BUFFER = 26
Draws the internal resolution buffer of the scene in linear colorspace before tonemapping or post-processing is applied.
Note: Only supported when using the Forward+ or Mobile rendering methods.
DebugDraw DEBUG_DRAW_CLUSTER_AREA_LIGHTS = 27
Draws the cluster used by AreaLight3D nodes to optimize light rendering.
Note: Only supported when using the Forward+ rendering method.
DebugDraw DEBUG_DRAW_AREA_LIGHT_ATLAS = 28
Draws the atlas used by AreaLight3D nodes in the upper left quadrant of the Viewport.
Note: Only supported when using the Forward+ or Mobile rendering method.
enum DefaultCanvasItemTextureFilter: 🔗
DefaultCanvasItemTextureFilter DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST = 0
紋理僅取最鄰近像素,近看呈現馬賽克,遠處因未取樣 mipmap 而顯得顆粒。
DefaultCanvasItemTextureFilter DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR = 1
紋理在最鄰近 4 像素間插值,近看平滑,遠處因未取樣 mipmap 仍顆粒。
DefaultCanvasItemTextureFilter DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS = 2
The texture filter blends between the nearest 4 pixels and between the nearest 2 mipmaps (or uses the nearest mipmap if ProjectSettings.rendering/textures/default_filters/use_nearest_mipmap_filter is true). This makes the texture look smooth from up close, and smooth from a distance.
Use this for non-pixel art textures that may be viewed at a low scale (e.g. due to Camera2D zoom or sprite scaling), as mipmaps are important to smooth out pixels that are smaller than on-screen pixels.
DefaultCanvasItemTextureFilter DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS = 3
The texture filter reads from the nearest pixel and blends between the nearest 2 mipmaps (or uses the nearest mipmap if ProjectSettings.rendering/textures/default_filters/use_nearest_mipmap_filter is true). This makes the texture look pixelated from up close, and smooth from a distance.
Use this for non-pixel art textures that may be viewed at a low scale (e.g. due to Camera2D zoom or sprite scaling), as mipmaps are important to smooth out pixels that are smaller than on-screen pixels.
DefaultCanvasItemTextureFilter DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_PARENT_NODE = 4
The Viewport will inherit the filter from its parent CanvasItem or Viewport.
DefaultCanvasItemTextureFilter DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_MAX = 5
Represents the size of the DefaultCanvasItemTextureFilter enum.
enum DefaultCanvasItemTextureRepeat: 🔗
DefaultCanvasItemTextureRepeat DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_DISABLED = 0
禁用紋理重複。相反,當讀取 0-1 範圍之外的 UV 時,該值將被鉗制在紋理的邊緣,從而導致紋理的邊界看起來被拉長。
DefaultCanvasItemTextureRepeat DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_ENABLED = 1
當 UV 超出 0–1 時允許紋理重複。如果使用線性過濾模式,取樣器跨越紋理邊界時可能在邊緣產生偽影。
DefaultCanvasItemTextureRepeat DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_MIRROR = 2
重複時翻轉該紋理,使邊緣對齊而不是突然改變。
DefaultCanvasItemTextureRepeat DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_PARENT_NODE = 3
The Viewport will inherit the repeat mode from its parent CanvasItem or Viewport.
DefaultCanvasItemTextureRepeat DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_MAX = 4
Represents the size of the DefaultCanvasItemTextureRepeat enum.
enum SDFOversize: 🔗
SDFOversize SDF_OVERSIZE_100_PERCENT = 0
The signed distance field only covers the viewport's own rectangle.
SDFOversize SDF_OVERSIZE_120_PERCENT = 1
The signed distance field is expanded to cover 20% of the viewport's size around the borders.
SDFOversize SDF_OVERSIZE_150_PERCENT = 2
The signed distance field is expanded to cover 50% of the viewport's size around the borders.
SDFOversize SDF_OVERSIZE_200_PERCENT = 3
The signed distance field is expanded to cover 100% (double) of the viewport's size around the borders.
SDFOversize SDF_OVERSIZE_MAX = 4
Represents the size of the SDFOversize enum.
enum SDFScale: 🔗
SDFScale SDF_SCALE_100_PERCENT = 0
The signed distance field is rendered at full resolution.
SDFScale SDF_SCALE_50_PERCENT = 1
The signed distance field is rendered at half the resolution of this viewport.
SDFScale SDF_SCALE_25_PERCENT = 2
The signed distance field is rendered at a quarter the resolution of this viewport.
SDFScale SDF_SCALE_MAX = 3
Represents the size of the SDFScale enum.
enum VRSMode: 🔗
VRSMode VRS_DISABLED = 0
Variable Rate Shading is disabled.
VRSMode VRS_TEXTURE = 1
Variable Rate Shading uses a texture. Note, for stereoscopic use a texture atlas with a texture for each view.
VRSMode VRS_XR = 2
Variable Rate Shading's texture is supplied by the primary XRInterface.
VRSMode VRS_MAX = 3
代表 VRSMode 列舉的大小。
enum VRSUpdateMode: 🔗
VRSUpdateMode VRS_UPDATE_DISABLED = 0
The input texture for variable rate shading will not be processed.
VRSUpdateMode VRS_UPDATE_ONCE = 1
The input texture for variable rate shading will be processed once.
VRSUpdateMode VRS_UPDATE_ALWAYS = 2
The input texture for variable rate shading will be processed each frame.
VRSUpdateMode VRS_UPDATE_MAX = 3
Represents the size of the VRSUpdateMode enum.
屬性說明
AnisotropicFiltering anisotropic_filtering_level = 2 🔗
void set_anisotropic_filtering_level(value: AnisotropicFiltering)
AnisotropicFiltering get_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 ProjectSettings.rendering/textures/decals/filter and ProjectSettings.rendering/textures/light_projectors/filter.
Note: In 3D, for this setting to have an effect, set BaseMaterial3D.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 CanvasItem.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.
bool audio_listener_enable_2d = false 🔗
如果為 true,該視口將處理 2D 音訊流。
bool audio_listener_enable_3d = false 🔗
如果為 true,該視口將處理 3D 音訊流。
int canvas_cull_mask = 4294967295 🔗
The rendering layers in which this Viewport renders CanvasItem nodes.
Note: A CanvasItem does not inherit its parents' visibility layers. See CanvasItem.visibility_layer's description for details.
DefaultCanvasItemTextureFilter canvas_item_default_texture_filter = 1 🔗
void set_default_canvas_item_texture_filter(value: DefaultCanvasItemTextureFilter)
DefaultCanvasItemTextureFilter get_default_canvas_item_texture_filter()
The default filter mode used by CanvasItem nodes in this viewport.
DefaultCanvasItemTextureRepeat canvas_item_default_texture_repeat = 0 🔗
void set_default_canvas_item_texture_repeat(value: DefaultCanvasItemTextureRepeat)
DefaultCanvasItemTextureRepeat get_default_canvas_item_texture_repeat()
The default repeat mode used by CanvasItem nodes in this viewport.
Transform2D canvas_transform 🔗
void set_canvas_transform(value: Transform2D)
Transform2D get_canvas_transform()
該視口的畫布變換,對改變所有子 CanvasItem 的螢幕位置很有用。相對於該視口的全域畫布變換。
在除錯時,用於測試算繪的幾何圖形的疊加模式。
禁用 3D 算繪(但保留 2D 算繪)。
確定使用 FSR 放大模式時,放大後的圖像的銳度。每個整數的銳度減半。值從 0.0(最銳利)到 2.0。高於 2.0 的值不會產生明顯的差異。
要在根視口上控制此屬性,請設定 ProjectSettings.rendering/scaling_3d/fsr_sharpness 專案設定。
Transform2D global_canvas_transform 🔗
void set_global_canvas_transform(value: Transform2D)
Transform2D get_global_canvas_transform()
該視口的全域畫布變換。畫布變換是相對於這個的。
bool gui_disable_input = false 🔗
如果為 true,該視口將不接收輸入事件。
The minimum distance the mouse cursor must move while pressed before a drag operation begins.
bool gui_embed_subwindows = false 🔗
如果為 true,子視窗(快顯視窗和對話方塊)將和控制項等節點一樣嵌入到套用程式視窗中。如果為 false,它們將顯示為作業系統處理的獨立窗口。
bool gui_snap_controls_to_pixels = true 🔗
如果為 true,該視口上的 GUI 控制項將完美地放置圖元。
bool handle_input_locally = true 🔗
如果為 true,則這個視口會把收到的輸入事件標記為已被自身處理。如果為 false,則由第一個設定本地處理輸入的父級視口進行這樣的操作。
SubViewportContainer 會自動將其包含的 Viewport 的這個屬性設定為 false。
另見 set_input_as_handled() 和 is_input_handled()。
float mesh_lod_threshold = 1.0 🔗
The automatic LOD bias to use for meshes rendered within the Viewport (this is analogous to ReflectionProbe.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 ProjectSettings.rendering/mesh_lod/lod_change/threshold_pixels project setting.
Note: Depending on the mesh's attributes (vertex colors, blend shapes, ...), a mesh may have fewer levels of LOD generated to avoid visible distortion of the mesh once it is affected by vertex colors or blend shapes. Meshes with a very low vertex count will also not have any LODs generated, which means this setting will not affect them at all. In general, this setting makes the largest impact on static meshes with a high vertex count.
Note: mesh_lod_threshold does not affect GeometryInstance3D visibility ranges (also known as "manual" LOD or hierarchical LOD).
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 MSAA_2X or MSAA_4X is best unless targeting very high-end systems. This has no effect on shader-induced aliasing or texture aliasing.
See also ProjectSettings.rendering/anti_aliasing/quality/msaa_2d and RenderingServer.viewport_set_msaa_2d().
The multisample antialiasing mode for 3D rendering. A higher number results in smoother edges at the cost of significantly worse performance. A value of MSAA_2X or 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 ProjectSettings.rendering/anti_aliasing/quality/msaa_3d and RenderingServer.viewport_set_msaa_3d().
If true and one of the following conditions are true: SubViewport.size_2d_override_stretch and SubViewport.size_2d_override are set, Window.content_scale_factor is set and scaling is enabled, oversampling_override is set, font and DPITexture oversampling are enabled.
float oversampling_override = 0.0 🔗
If greater than zero, this value is used as the font oversampling factor, otherwise oversampling is equal to viewport scale.
如果為 true,則該視口會使用 world_3d 中定義的 World3D 的唯一副本。
bool physics_object_picking = false 🔗
如果true,則視埠算繪的物件將成為滑鼠擷取過程的主題。
注意:同時可拾取物件的數量限制為 64 個,並且它們以不確定的順序選擇,在每個拾取過程中可能不同。
bool physics_object_picking_first_only = false 🔗
void set_physics_object_picking_first_only(value: bool)
bool get_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.
bool physics_object_picking_sort = false 🔗
如果為 true,物件接收滑鼠拾取事件的順序,主要按它們的 CanvasItem.z_index 排序,其次按它們在場景樹中的位置排序。如果為 false,則順序不確定。
注意:預設情況下禁用此設定,因為它可能會產生昂貴的計算成本。
bool positional_shadow_atlas_16_bits = true 🔗
使用 16 位的全向燈/聚光燈陰影深度貼圖。啟用後,陰影的精度會降低,可能造成陰影失真,但能夠在部分裝置上提升性能。
PositionalShadowAtlasQuadrantSubdiv positional_shadow_atlas_quad_0 = 2 🔗
void set_positional_shadow_atlas_quadrant_subdiv(quadrant: int, subdiv: PositionalShadowAtlasQuadrantSubdiv)
PositionalShadowAtlasQuadrantSubdiv get_positional_shadow_atlas_quadrant_subdiv(quadrant: int) const
陰影合集上第一象限的細分量。
PositionalShadowAtlasQuadrantSubdiv positional_shadow_atlas_quad_1 = 2 🔗
void set_positional_shadow_atlas_quadrant_subdiv(quadrant: int, subdiv: PositionalShadowAtlasQuadrantSubdiv)
PositionalShadowAtlasQuadrantSubdiv get_positional_shadow_atlas_quadrant_subdiv(quadrant: int) const
陰影合集上第二象限的細分量。
PositionalShadowAtlasQuadrantSubdiv positional_shadow_atlas_quad_2 = 3 🔗
void set_positional_shadow_atlas_quadrant_subdiv(quadrant: int, subdiv: PositionalShadowAtlasQuadrantSubdiv)
PositionalShadowAtlasQuadrantSubdiv get_positional_shadow_atlas_quadrant_subdiv(quadrant: int) const
陰影合集上第三象限的細分量。
PositionalShadowAtlasQuadrantSubdiv positional_shadow_atlas_quad_3 = 4 🔗
void set_positional_shadow_atlas_quadrant_subdiv(quadrant: int, subdiv: PositionalShadowAtlasQuadrantSubdiv)
PositionalShadowAtlasQuadrantSubdiv get_positional_shadow_atlas_quadrant_subdiv(quadrant: int) const
陰影合集上第四象限的細分量。
int positional_shadow_atlas_size = 2048 🔗
陰影合集的解析度(用於全向燈和聚光燈)。該值將向上四捨五入到最接近的 2 次冪。
注意:如果設定為 0,將根本看不到任何陰影(包括定向陰影)。可以通過降低 CPU 和 GPU 負載來顯著提升在低端系統上的性能(因為繪製不帶陰影的場景需要的繪製呼叫更少)。
Scaling3DMode scaling_3d_mode = 0 🔗
void set_scaling_3d_mode(value: Scaling3DMode)
Scaling3DMode get_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 ProjectSettings.rendering/scaling_3d/mode project setting.
float scaling_3d_scale = 1.0 🔗
根據視口大小縮放 3D 算繪緩衝區,使用 ProjectSettings.rendering/scaling_3d/mode 中指定的圖像篩檢程式將輸出圖像縮放到完整的視口大小。比 1.0 小的值可以犧牲品質加速 3D 算繪(欠取樣)。比 1.0 大的值僅在雙線性模式下可用,可以提升 3D 算繪品質,但性能消耗較高(超采樣)。另見多重取樣抗鋸齒 ProjectSettings.rendering/anti_aliasing/quality/msaa_3d,性能消耗明顯更低,但只會對多邊形的邊緣進行平滑。
使用 FSR 放大時,AMD 推薦將以下值作為預設選項暴露給使用者“極致品質:0.77”“質量:0.67”“平衡:0.59”“性能:0.5”,不暴露特定的縮放值。
要在根視口上控制這個屬性,請使用專案設定 ProjectSettings.rendering/scaling_3d/scale。
ScreenSpaceAA screen_space_aa = 0 🔗
void set_screen_space_aa(value: ScreenSpaceAA)
ScreenSpaceAA get_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 ProjectSettings.rendering/anti_aliasing/quality/screen_space_aa and RenderingServer.viewport_set_screen_space_aa().
SDFOversize sdf_oversize = 1 🔗
void set_sdf_oversize(value: SDFOversize)
SDFOversize get_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 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).
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.
bool snap_2d_transforms_to_pixel = false 🔗
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.
bool snap_2d_vertices_to_pixel = false 🔗
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.
float texture_mipmap_bias = 0.0 🔗
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.
To control this property on the root viewport, set the ProjectSettings.rendering/textures/default_filters/texture_mipmap_bias project setting.
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.
Note: This property is only supported in the Forward+ and Mobile renderers, not Compatibility. In Compatibility, this property is always treated as if it was set to 0.0.
如果為真,則視口背景應渲染為透明。
注意: 由於技術限制,當視口背景透明時,某些渲染功能將被停用。目前,螢幕空間反射、次表面散射和景深效果均會受到影響。
When using the Mobile or Forward+ renderers, set use_debanding to enable or disable the debanding feature of this Viewport. If use_hdr_2d is false, 2D rendering is not affected by debanding unless the Environment.background_mode is Environment.BG_CANVAS. If use_hdr_2d is true, debanding will only be applied if this is the root Viewport and will affect all 2D and 3D rendering, including canvas items.
use_debanding has no effect when using the Compatibility rendering method. The Mobile renderer can also use material debanding, which can be set with RenderingServer.material_set_use_debanding() or configured with ProjectSettings.rendering/anti_aliasing/quality/use_debanding.
See also ProjectSettings.rendering/anti_aliasing/quality/use_debanding, RenderingServer.material_set_use_debanding(), and RenderingServer.viewport_set_use_debanding().
If true, 2D rendering will use a high dynamic range (HDR) RGBA16 format framebuffer. Additionally, 2D rendering will be performed on linear values and will be converted using the appropriate transfer function 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 to the 0-1 range and can be used in 3D rendering without color encoding 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.
bool use_occlusion_culling = false 🔗
如果為 true,OccluderInstance3D 節點將被用於該視口中的 3D 遮擋剔除。對於根視口,ProjectSettings.rendering/occlusion_culling/use_occlusion_culling 必須改為被設定為 true。
注意:啟用遮擋剔除會消耗一定的 CPU。僅當確實打算使用遮擋剔除時才啟用它,並考慮場景是否真的可以從遮擋剔除中受益。具有很少或沒有物件阻擋視圖的大型開放場景,通常不會從遮擋剔除中受益更多。與遮擋剔除相比,大型開放場景通常從網格 LOD 和可見性範圍(GeometryInstance3D.visibility_range_begin 和 GeometryInstance3D.visibility_range_end)中受益更多。
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 ProjectSettings.rendering/anti_aliasing/quality/use_taa and RenderingServer.viewport_set_use_taa().
如果為 true,則視口將使用主 XR 介面來算繪 XR 輸出。如果適用,這可以得到立體圖像,算繪結果會輸出到頭戴裝置。
用於這個視口的可變速率著色(Variable Rate Shading,VRS)模式。請注意,如果硬件不支援 VRS,則會忽略此屬性。
Texture to use when vrs_mode is set to 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
VRSUpdateMode vrs_update_mode = 1 🔗
void set_vrs_update_mode(value: VRSUpdateMode)
VRSUpdateMode get_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.
自訂的 World2D,可以作為 2D 環境源。
自訂的 World3D,可以作為 3D 環境源。
方法說明
World2D find_world_2d() const 🔗
返回該視口的首個有效 World2D,在它自身及任何 Viewport 祖先節點的 world_2d 屬性中搜尋。
World3D find_world_3d() const 🔗
返回這個視口的第一個有效 World3D,會在自身和 Viewport 祖先的 world_3d 屬性中搜索。
AudioListener2D get_audio_listener_2d() 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.
AudioListener3D get_audio_listener_3d() 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.
Camera2D get_camera_2d() const 🔗
Returns the currently active 2D camera. Returns null if there are no active cameras.
Note: If called while the Camera Override system is active in editor, this will return the internally managed override camera. It is therefore advised to avoid caching the return value, or to check that the cached value is still a valid instance and is the current camera before use. See @GlobalScope.is_instance_valid() and Camera2D.is_current().
Camera3D get_camera_3d() const 🔗
Returns the currently active 3D camera. Returns null if there are no active cameras.
Note: If called while the Camera Override system is active in editor, this will return the internally managed override camera. It is therefore advised to avoid caching the return value, or to check that the cached value is a valid instance and is the current camera before use. See @GlobalScope.is_instance_valid() and Camera3D.current.
bool get_canvas_cull_mask_bit(layer: int) const 🔗
返回算繪層遮罩上的某個比特位。
Array[Window] get_embedded_subwindows() const 🔗
傳回視窗內可見嵌入 Window 的列表。
注意: 其他視窗內的Window不會列出。
Transform2D get_final_transform() const 🔗
返回從該視口的坐標系到嵌入器坐標系統的變換。
Vector2 get_mouse_position() const 🔗
返回該 Viewport 中滑鼠的位置,使用該 Viewport 的坐標系。
float get_oversampling() const 🔗
Returns viewport oversampling factor.
PositionalShadowAtlasQuadrantSubdiv get_positional_shadow_atlas_quadrant_subdiv(quadrant: int) const 🔗
Returns the positional shadow atlas quadrant subdivision of the specified quadrant.
int get_render_info(type: RenderInfoType, info: RenderInfo) 🔗
Returns rendering statistics of the given type.
Transform2D get_screen_transform() const 🔗
返回從視口的座標到包含視窗管理器視窗的螢幕座標的變換。
Transform2D get_stretch_transform() const 🔗
Returns the automatically computed 2D stretch transform, taking the Viewport's stretch settings into account. The final value is multiplied by Window.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 Transform2D.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 Window.content_scale_aspect is set to a mode that preserves the pixels' aspect ratio. If Window.content_scale_aspect is Window.CONTENT_SCALE_ASPECT_IGNORE, the X and Y scale may differ significantly.
ViewportTexture get_texture() 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. Node._ready(). To make sure the texture you get is correct, you can await RenderingServer.frame_post_draw signal.
func _ready():
await RenderingServer.frame_post_draw
$Viewport.get_texture().get_image().save_png("user://Screenshot.png")
public async override void _Ready()
{
await ToSignal(RenderingServer.Singleton, RenderingServer.SignalName.FramePostDraw);
var viewport = GetNode<Viewport>("Viewport");
viewport.GetTexture().GetImage().SavePng("user://Screenshot.png");
}
Note: When use_hdr_2d is true the returned texture will be an HDR image using linear encoding.
RID get_viewport_rid() const 🔗
返回該視口在 RenderingServer 的 RID。
Rect2 get_visible_rect() const 🔗
返回全域螢幕座標中的可見矩形。
void gui_cancel_drag() 🔗
Cancels the drag operation that was previously started through Control._get_drag_data() or forced with Control.force_drag().
Variant gui_get_drag_data() const 🔗
返回 GUI 的拖動資料,該資料先前由 Control._get_drag_data() 返回。
String gui_get_drag_description() const 🔗
Returns the human-readable description of the drag data, used for assistive apps.
Control gui_get_focus_owner() const 🔗
Returns the currently focused Control within this viewport. If no Control is focused, returns null.
Control gui_get_hovered_control() 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.
bool gui_is_drag_successful() const 🔗
如果拖拽操作成功,則返回 true。
bool gui_is_dragging() const 🔗
Returns true if a drag operation is currently ongoing and where the drop action could happen in this viewport.
Alternative to Node.NOTIFICATION_DRAG_BEGIN and Node.NOTIFICATION_DRAG_END when you prefer polling the value.
void gui_release_focus() 🔗
移除這個視口中目前聚焦 Control 的焦點。如果沒有聚焦任何 Control,則什麼都不做。
void gui_set_drag_description(description: String) 🔗
Sets the human-readable description of the drag data to description, used for assistive apps.
bool is_input_handled() const 🔗
返回目前的 InputEvent 是否已被處理。在 InputEvent 生命週期中呼叫 set_input_as_handled() 前,輸入事件都處於未處理狀態。
通常作為 Node._input()、Control._gui_input() 等輸入處理方法以及對應的訊號處理函式的一部分來實作。
如果 handle_input_locally 為 false,則這個方法會嘗試查找第一個本地處理輸入的父級視口,並返回該視口的 is_input_handled()。
void 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 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_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 push_input(event: InputEvent, in_local_coords: bool = false) 🔗
在該 Viewport 中觸發給定的 event 事件。可用於在不同視口之間傳遞 InputEvent,或者在本地套用通過網路傳輸或保存在檔中的事件。
如果 in_local_coords 為 false,則該事件中的位置使用的是嵌入器坐標系,會被轉換至視口坐標系。如果 in_local_coords 為 true,則該事件的位置使用的是視口坐標系。
雖然這個方法的用途和 Input.parse_input_event() 類似,但不會根據 ProjectSettings.input_devices/pointing/emulate_touch_from_mouse 等項目設定對指定的 event 進行重對應。
呼叫這個方法會將呼叫傳播至子節點,按照以下順序呼叫:
Control._gui_input() 僅用於 Control 節點
如果某個方法使用 set_input_as_handled() 將輸入標記為已處理,則列表中的後續方法均不會被呼叫。
如果上述方法均未處理事件,並且 physics_object_picking 為 true,則該事件將用於物理物件的拾取。
void push_text_input(text: String) 🔗
輔助方法,會呼叫目前聚焦 Control 的 set_text() 方法,前提是該控制項上定義了這個方法(例如聚焦 Control 為 Button 或 LineEdit)。
void push_unhandled_input(event: InputEvent, in_local_coords: bool = false) 🔗
已棄用: Use push_input() instead.
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:
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 set_canvas_cull_mask_bit(layer: int, enable: bool) 🔗
設定或清除碰撞遮罩上的比特位。可以簡化 Viewport 層的編輯。
void set_input_as_handled() 🔗
Stops the input from propagating further up the SceneTree.
Note: This does not affect the methods in Input, only the way events are propagated.
void set_positional_shadow_atlas_quadrant_subdiv(quadrant: int, subdiv: PositionalShadowAtlasQuadrantSubdiv) 🔗
設定在指定象限內使用的細分數。較多的細分數可以讓你在場景中一次擁有更多的陰影,但是會降低陰影的品質。一個好的做法是讓象限具有不同數量的細分,並盡可能地減少細分。
void update_mouse_cursor_state() 🔗
根據目前滑鼠游標的位置強制立即更新顯示。包括更新滑鼠游標的形狀以及發送必要的 Control.mouse_entered、CollisionObject2D.mouse_entered、CollisionObject3D.mouse_entered、Window.mouse_entered 等信號,以及這些訊號對應的 mouse_exited 版本。
void warp_mouse(position: Vector2) 🔗
使用該 Viewport 的坐標系,將滑鼠指標移動到該 Viewport 中的指定位置。
注意:warp_mouse() 僅支援 Windows、macOS 和 Linux。它對 Android、iOS 和 Web 沒有影響。