Up to date
This page is up to date for Godot 4.2
.
If you still find outdated information, please open an issue.
ViewportTexture¶
继承: Texture2D < Texture < Resource < RefCounted < Object
以动态纹理的形式提供 Viewport 的内容。
描述¶
以动态 Texture2D 的形式提供 Viewport 的内容。可用于在同一场景中混合控件、2D 游戏对象和 3D 游戏对象。
要在代码中创建 ViewportTexture,请在目标视口上使用 Viewport.get_texture 方法。
注意:ViewportTexture 始终是局部于其场景的(请参阅 Resource.resource_local_to_scene)。如果该场景根没有准备好,它可能会返回不正确的数据(参见 Node.ready)。
教程¶
属性¶
|
属性说明¶
NodePath viewport_path = NodePath("")
要显示的 Viewport 节点的路径。相对于场景的根节点,而不是使用纹理的节点。
注意:在编辑器中,目标视口或其祖级节点发生重命名或移动时会自动更新这个路径。在运行时,该路径可能无法自动更新,因为无法确定场景的根节点。