: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/EditorResourceConversionPlugin.xml. .. _class_EditorResourceConversionPlugin: EditorResourceConversionPlugin ============================== **Inherits:** :ref:`RefCounted` **<** :ref:`Object` Plugin for adding custom converters from one resource format to another in the editor resource picker context menu; for example, converting a :ref:`StandardMaterial3D` to a :ref:`ShaderMaterial`. .. rst-class:: classref-introduction-group Description ----------- **EditorResourceConversionPlugin** is invoked when the context menu is brought up for a resource in the editor inspector. Relevant conversion plugins will appear as menu options to convert the given resource to a target type. Below shows an example of a basic plugin that will convert an :ref:`ImageTexture` to a :ref:`PortableCompressedTexture2D`. .. tabs:: .. code-tab:: gdscript extends EditorResourceConversionPlugin func _handles(resource: Resource): return resource is ImageTexture func _converts_to(): return "PortableCompressedTexture2D" func _convert(itex: Resource): var ptex = PortableCompressedTexture2D.new() ptex.create_from_image(itex.get_image(), PortableCompressedTexture2D.COMPRESSION_MODE_LOSSLESS) return ptex To use an **EditorResourceConversionPlugin**, register it using the :ref:`EditorPlugin.add_resource_conversion_plugin()` method first. .. rst-class:: classref-reftable-group Methods ------- .. table:: :widths: auto +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Resource` | :ref:`_convert`\ (\ resource\: :ref:`Resource`\ ) |virtual| |const| | +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`_converts_to`\ (\ ) |virtual| |const| | +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`_handles`\ (\ resource\: :ref:`Resource`\ ) |virtual| |const| | +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Method Descriptions ------------------- .. _class_EditorResourceConversionPlugin_private_method__convert: .. rst-class:: classref-method :ref:`Resource` **_convert**\ (\ resource\: :ref:`Resource`\ ) |virtual| |const| :ref:`🔗` Takes an input :ref:`Resource` and converts it to the type given in :ref:`_converts_to()`. The returned :ref:`Resource` is the result of the conversion, and the input :ref:`Resource` remains unchanged. .. rst-class:: classref-item-separator ---- .. _class_EditorResourceConversionPlugin_private_method__converts_to: .. rst-class:: classref-method :ref:`String` **_converts_to**\ (\ ) |virtual| |const| :ref:`🔗` Returns the class name of the target type of :ref:`Resource` that this plugin converts source resources to. .. rst-class:: classref-item-separator ---- .. _class_EditorResourceConversionPlugin_private_method__handles: .. rst-class:: classref-method :ref:`bool` **_handles**\ (\ resource\: :ref:`Resource`\ ) |virtual| |const| :ref:`🔗` Called to determine whether a particular :ref:`Resource` can be converted to the target resource type by this plugin. .. |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.)`