0.2.0-dev Download ZIP
65 lines ·3.4 KB Raw
| 1 | <?xml version="1.0" encoding="UTF-8" ?> |
| 2 | <class name="EditorResourcePreviewGenerator" inherits="RefCounted" api_type="editor" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> |
| 3 | <brief_description> |
| 4 | Custom generator of previews. |
| 5 | </brief_description> |
| 6 | <description> |
| 7 | Custom code to generate previews. Check [member EditorSettings.filesystem/file_dialog/thumbnail_size] to find a proper size to generate previews at. |
| 8 | </description> |
| 9 | <tutorials> |
| 10 | </tutorials> |
| 11 | <methods> |
| 12 | <method name="_can_generate_small_preview" qualifiers="virtual const"> |
| 13 | <return type="bool" /> |
| 14 | <description> |
| 15 | If this function returns [code]true[/code], the generator will call [method _generate] or [method _generate_from_path] for small previews as well. |
| 16 | By default, it returns [code]false[/code]. |
| 17 | </description> |
| 18 | </method> |
| 19 | <method name="_generate" qualifiers="virtual required const"> |
| 20 | <return type="Texture2D" /> |
| 21 | <param index="0" name="resource" type="Resource" /> |
| 22 | <param index="1" name="size" type="Vector2i" /> |
| 23 | <param index="2" name="metadata" type="Dictionary" /> |
| 24 | <description> |
| 25 | Generate a preview from a given resource with the specified size. This must always be implemented. |
| 26 | Returning [code]null[/code] is an OK way to fail and let another generator take care. |
| 27 | Care must be taken because this function is always called from a thread (not the main thread). |
| 28 | [param metadata] dictionary can be modified to store file-specific metadata that can be used in [method EditorResourceTooltipPlugin._make_tooltip_for_path] (like image size, sample length etc.). |
| 29 | </description> |
| 30 | </method> |
| 31 | <method name="_generate_from_path" qualifiers="virtual const"> |
| 32 | <return type="Texture2D" /> |
| 33 | <param index="0" name="path" type="String" /> |
| 34 | <param index="1" name="size" type="Vector2i" /> |
| 35 | <param index="2" name="metadata" type="Dictionary" /> |
| 36 | <description> |
| 37 | Generate a preview directly from a path with the specified size. Implementing this is optional, as default code will load and call [method _generate]. |
| 38 | Returning [code]null[/code] is an OK way to fail and let another generator take care. |
| 39 | Care must be taken because this function is always called from a thread (not the main thread). |
| 40 | [param metadata] dictionary can be modified to store file-specific metadata that can be used in [method EditorResourceTooltipPlugin._make_tooltip_for_path] (like image size, sample length etc.). |
| 41 | </description> |
| 42 | </method> |
| 43 | <method name="_generate_small_preview_automatically" qualifiers="virtual const"> |
| 44 | <return type="bool" /> |
| 45 | <description> |
| 46 | If this function returns [code]true[/code], the generator will automatically generate the small previews from the normal preview texture generated by the methods [method _generate] or [method _generate_from_path]. |
| 47 | By default, it returns [code]false[/code]. |
| 48 | </description> |
| 49 | </method> |
| 50 | <method name="_handles" qualifiers="virtual required const"> |
| 51 | <return type="bool" /> |
| 52 | <param index="0" name="type" type="String" /> |
| 53 | <description> |
| 54 | Returns [code]true[/code] if your generator supports the resource of type [param type]. |
| 55 | </description> |
| 56 | </method> |
| 57 | <method name="request_draw_and_wait" qualifiers="const"> |
| 58 | <return type="void" /> |
| 59 | <param index="0" name="viewport" type="RID" /> |
| 60 | <description> |
| 61 | Call from within [method _generate] to request the rendering server draw to the [param viewport]. |
| 62 | </description> |
| 63 | </method> |
| 64 | </methods> |
| 65 | </class> |