:github_url: hide .. _class_EditorResourcePreviewGenerator: EditorResourcePreviewGenerator ============================== **Hereda:** :ref:`RefCounted` **<** :ref:`Object` Generador personalizado de vistas previas. .. rst-class:: classref-introduction-group Descripción ---------------------- Código personalizado para generar vistas previas. Comprueba :ref:`EditorSettings.filesystem/file_dialog/thumbnail_size` para encontrar un tamaño adecuado para generar las vistas previas. .. rst-class:: classref-reftable-group Métodos -------------- .. table:: :widths: auto +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`_can_generate_small_preview`\ (\ ) |virtual| |const| | +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Texture2D` | :ref:`_generate`\ (\ resource\: :ref:`Resource`, size\: :ref:`Vector2i`, metadata\: :ref:`Dictionary`\ ) |virtual| |required| |const| | +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Texture2D` | :ref:`_generate_from_path`\ (\ path\: :ref:`String`, size\: :ref:`Vector2i`, metadata\: :ref:`Dictionary`\ ) |virtual| |const| | +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`_generate_small_preview_automatically`\ (\ ) |virtual| |const| | +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`_handles`\ (\ type\: :ref:`String`\ ) |virtual| |required| |const| | +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`request_draw_and_wait`\ (\ viewport\: :ref:`RID`\ ) |const| | +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Descripciones de Métodos ------------------------------------------------ .. _class_EditorResourcePreviewGenerator_private_method__can_generate_small_preview: .. rst-class:: classref-method :ref:`bool` **_can_generate_small_preview**\ (\ ) |virtual| |const| :ref:`🔗` If this function returns ``true``, the generator will call :ref:`_generate()` or :ref:`_generate_from_path()` for small previews as well. By default, it returns ``false``. .. rst-class:: classref-item-separator ---- .. _class_EditorResourcePreviewGenerator_private_method__generate: .. rst-class:: classref-method :ref:`Texture2D` **_generate**\ (\ resource\: :ref:`Resource`, size\: :ref:`Vector2i`, metadata\: :ref:`Dictionary`\ ) |virtual| |required| |const| :ref:`🔗` Generate a preview from a given resource with the specified size. This must always be implemented. Returning ``null`` is an OK way to fail and let another generator take care. Care must be taken because this function is always called from a thread (not the main thread). \ ``metadata`` dictionary can be modified to store file-specific metadata that can be used in :ref:`EditorResourceTooltipPlugin._make_tooltip_for_path()` (like image size, sample length etc.). .. rst-class:: classref-item-separator ---- .. _class_EditorResourcePreviewGenerator_private_method__generate_from_path: .. rst-class:: classref-method :ref:`Texture2D` **_generate_from_path**\ (\ path\: :ref:`String`, size\: :ref:`Vector2i`, metadata\: :ref:`Dictionary`\ ) |virtual| |const| :ref:`🔗` Generate a preview directly from a path with the specified size. Implementing this is optional, as default code will load and call :ref:`_generate()`. Returning ``null`` is an OK way to fail and let another generator take care. Care must be taken because this function is always called from a thread (not the main thread). \ ``metadata`` dictionary can be modified to store file-specific metadata that can be used in :ref:`EditorResourceTooltipPlugin._make_tooltip_for_path()` (like image size, sample length etc.). .. rst-class:: classref-item-separator ---- .. _class_EditorResourcePreviewGenerator_private_method__generate_small_preview_automatically: .. rst-class:: classref-method :ref:`bool` **_generate_small_preview_automatically**\ (\ ) |virtual| |const| :ref:`🔗` If this function returns ``true``, the generator will automatically generate the small previews from the normal preview texture generated by the methods :ref:`_generate()` or :ref:`_generate_from_path()`. By default, it returns ``false``. .. rst-class:: classref-item-separator ---- .. _class_EditorResourcePreviewGenerator_private_method__handles: .. rst-class:: classref-method :ref:`bool` **_handles**\ (\ type\: :ref:`String`\ ) |virtual| |required| |const| :ref:`🔗` Returns ``true`` if your generator supports the resource of type ``type``. .. rst-class:: classref-item-separator ---- .. _class_EditorResourcePreviewGenerator_method_request_draw_and_wait: .. rst-class:: classref-method |void| **request_draw_and_wait**\ (\ viewport\: :ref:`RID`\ ) |const| :ref:`🔗` Call from within :ref:`_generate()` to request the rendering server draw to the ``viewport``. .. |virtual| replace:: :abbr:`virtual (Normalmente, este método debería ser sobreescrito por el usuario para que tenga algún efecto.)` .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)` .. |const| replace:: :abbr:`const (Este método no tiene efectos secundarios. No modifica ninguna de las variables miembro de la instancia.)` .. |vararg| replace:: :abbr:`vararg (Este método permite agregar cualquier número de argumentos después de los descritos aquí.)` .. |constructor| replace:: :abbr:`constructor (Este método se utiliza para construir un tipo.)` .. |static| replace:: :abbr:`static (Este método no necesita una instancia para ser llamado, por lo que puede llamarse directamente utilizando el nombre de la clase.)` .. |operator| replace:: :abbr:`operator (Este método describe un operador válido para usar con este tipo como operando izquierdo.)` .. |bitfield| replace:: :abbr:`BitField (Este valor es un entero compuesto como una máscara de bits de las siguientes banderas.)` .. |void| replace:: :abbr:`void (Sin valor de retorno.)`