EditorResourceConversionPlugin
继承: RefCounted
< Object
Plugin for adding custom converters from one resource format to another in the editor resource picker context menu; for example, converting a StandardMaterial3D
to a ShaderMaterial
.
描述
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 ImageTexture
to a PortableCompressedTexture2D
.
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 EditorPlugin.add_resource_conversion_plugin
method first.
方法
Resource | _convert ( resource: Resource ) virtual1 const2 |
String | _converts_to ( ) virtual1 const2 |
bool | _handles ( resource: Resource ) virtual1 const2 |
方法说明
Resource
_convert ( resource: Resource
) virtual1 const2
Takes an input Resource
and converts it to the type given in _converts_to
. The returned Resource
is the result of the conversion, and the input Resource
remains unchanged.
String
_converts_to ( ) virtual1 const2
Returns the class name of the target type of Resource
that this plugin converts source resources to.
bool
_handles ( resource: Resource
) virtual1 const2
Called to determine whether a particular Resource
can be converted to the target resource type by this plugin.
本方法通常需要用户覆盖才能生效。
本方法无副作用,不会修改该实例的任何成员变量。
本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。
本方法用于构造某个类型。
调用本方法无需实例,可直接使用类名进行调用。
本方法描述的是使用本类型作为左操作数的有效运算符。
这个值是由下列位标志构成位掩码的整数。
无返回值。