:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/SubViewport.xml. .. _class_SubViewport: SubViewport =========== **Inherits:** :ref:`Viewport` **<** :ref:`Node` **<** :ref:`Object` An interface to a game world that doesn't create a window or draw to the screen directly. .. rst-class:: classref-introduction-group 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 :ref:`Viewport` that isn't a :ref:`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 :ref:`SubViewportContainer` or assigned to a :ref:`ViewportTexture`. \ **Note:** :ref:`InputEvent`\ s are not passed to a standalone **SubViewport** by default. To ensure :ref:`InputEvent` propagation, a **SubViewport** can be placed inside of a :ref:`SubViewportContainer`. .. rst-class:: classref-introduction-group Tutorials --------- - :doc:`Using Viewports <../tutorials/rendering/viewports>` - :doc:`Viewport and canvas transforms <../tutorials/2d/2d_transforms>` - `GUI in 3D Viewport Demo `__ - `3D in 2D Viewport Demo `__ - `2D in 3D Viewport Demo `__ - `Screen Capture Demo `__ - `Dynamic Split Screen Demo `__ - `3D Resolution Scaling Demo `__ .. rst-class:: classref-reftable-group Properties ---------- .. table:: :widths: auto +------------------------------------------------+----------------------------------------------------------------------------------------+------------------------+ | :ref:`ClearMode` | :ref:`render_target_clear_mode` | ``0`` | +------------------------------------------------+----------------------------------------------------------------------------------------+------------------------+ | :ref:`UpdateMode` | :ref:`render_target_update_mode` | ``2`` | +------------------------------------------------+----------------------------------------------------------------------------------------+------------------------+ | :ref:`Vector2i` | :ref:`size` | ``Vector2i(512, 512)`` | +------------------------------------------------+----------------------------------------------------------------------------------------+------------------------+ | :ref:`Vector2i` | :ref:`size_2d_override` | ``Vector2i(0, 0)`` | +------------------------------------------------+----------------------------------------------------------------------------------------+------------------------+ | :ref:`bool` | :ref:`size_2d_override_stretch` | ``false`` | +------------------------------------------------+----------------------------------------------------------------------------------------+------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Enumerations ------------ .. _enum_SubViewport_ClearMode: .. rst-class:: classref-enumeration enum **ClearMode**: :ref:`🔗` .. _class_SubViewport_constant_CLEAR_MODE_ALWAYS: .. rst-class:: classref-enumeration-constant :ref:`ClearMode` **CLEAR_MODE_ALWAYS** = ``0`` Always clear the render target before drawing. .. _class_SubViewport_constant_CLEAR_MODE_NEVER: .. rst-class:: classref-enumeration-constant :ref:`ClearMode` **CLEAR_MODE_NEVER** = ``1`` Never clear the render target. .. _class_SubViewport_constant_CLEAR_MODE_ONCE: .. rst-class:: classref-enumeration-constant :ref:`ClearMode` **CLEAR_MODE_ONCE** = ``2`` Clear the render target on the next frame, then switch to :ref:`CLEAR_MODE_NEVER`. .. rst-class:: classref-item-separator ---- .. _enum_SubViewport_UpdateMode: .. rst-class:: classref-enumeration enum **UpdateMode**: :ref:`🔗` .. _class_SubViewport_constant_UPDATE_DISABLED: .. rst-class:: classref-enumeration-constant :ref:`UpdateMode` **UPDATE_DISABLED** = ``0`` Do not update the render target. .. _class_SubViewport_constant_UPDATE_ONCE: .. rst-class:: classref-enumeration-constant :ref:`UpdateMode` **UPDATE_ONCE** = ``1`` Update the render target once, then switch to :ref:`UPDATE_DISABLED`. .. _class_SubViewport_constant_UPDATE_WHEN_VISIBLE: .. rst-class:: classref-enumeration-constant :ref:`UpdateMode` **UPDATE_WHEN_VISIBLE** = ``2`` Update the render target only when it is visible. This is the default value. .. _class_SubViewport_constant_UPDATE_WHEN_PARENT_VISIBLE: .. rst-class:: classref-enumeration-constant :ref:`UpdateMode` **UPDATE_WHEN_PARENT_VISIBLE** = ``3`` Update the render target only when its parent is visible. .. _class_SubViewport_constant_UPDATE_ALWAYS: .. rst-class:: classref-enumeration-constant :ref:`UpdateMode` **UPDATE_ALWAYS** = ``4`` Always update the render target. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Property Descriptions --------------------- .. _class_SubViewport_property_render_target_clear_mode: .. rst-class:: classref-property :ref:`ClearMode` **render_target_clear_mode** = ``0`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_clear_mode**\ (\ value\: :ref:`ClearMode`\ ) - :ref:`ClearMode` **get_clear_mode**\ (\ ) The clear mode when the sub-viewport is used as a render target. \ **Note:** This property is intended for 2D usage. .. rst-class:: classref-item-separator ---- .. _class_SubViewport_property_render_target_update_mode: .. rst-class:: classref-property :ref:`UpdateMode` **render_target_update_mode** = ``2`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_update_mode**\ (\ value\: :ref:`UpdateMode`\ ) - :ref:`UpdateMode` **get_update_mode**\ (\ ) The update mode when the sub-viewport is used as a render target. .. rst-class:: classref-item-separator ---- .. _class_SubViewport_property_size: .. rst-class:: classref-property :ref:`Vector2i` **size** = ``Vector2i(512, 512)`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_size**\ (\ value\: :ref:`Vector2i`\ ) - :ref:`Vector2i` **get_size**\ (\ ) The width and height of the sub-viewport. Must be set to a value greater than or equal to 2 pixels on both dimensions. Otherwise, nothing will be displayed. \ **Note:** If the parent node is a :ref:`SubViewportContainer` and its :ref:`SubViewportContainer.stretch` is ``true``, the viewport size cannot be changed manually. .. rst-class:: classref-item-separator ---- .. _class_SubViewport_property_size_2d_override: .. rst-class:: classref-property :ref:`Vector2i` **size_2d_override** = ``Vector2i(0, 0)`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_size_2d_override**\ (\ value\: :ref:`Vector2i`\ ) - :ref:`Vector2i` **get_size_2d_override**\ (\ ) The 2D size override of the sub-viewport. If either the width or height is ``0``, the override is disabled. .. rst-class:: classref-item-separator ---- .. _class_SubViewport_property_size_2d_override_stretch: .. rst-class:: classref-property :ref:`bool` **size_2d_override_stretch** = ``false`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_size_2d_override_stretch**\ (\ value\: :ref:`bool`\ ) - :ref:`bool` **is_size_2d_override_stretch_enabled**\ (\ ) If ``true``, the 2D size override affects stretch as well. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)` .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)` .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)` .. |void| replace:: :abbr:`void (No return value.)`