Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

EditorResourcePreviewGenerator

繼承: RefCounted < Object

自訂的預覽生成器。

說明

Custom code to generate previews. Check EditorSettings.filesystem/file_dialog/thumbnail_size to find a proper size to generate previews at.

方法

bool

_can_generate_small_preview() virtual const

Texture2D

_generate(resource: Resource, size: Vector2i, metadata: Dictionary) virtual required const

Texture2D

_generate_from_path(path: String, size: Vector2i, metadata: Dictionary) virtual const

bool

_generate_small_preview_automatically() virtual const

bool

_handles(type: String) virtual required const

void

request_draw_and_wait(viewport: RID) const


方法說明

bool _can_generate_small_preview() virtual const 🔗

如果該函式返回 true,則該生成器也會為小型預覽呼叫 _generate()_generate_from_path()

預設情況下,它返回 false


Texture2D _generate(resource: Resource, size: Vector2i, metadata: Dictionary) virtual required const 🔗

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 EditorResourceTooltipPlugin._make_tooltip_for_path() (like image size, sample length etc.).


Texture2D _generate_from_path(path: String, size: Vector2i, metadata: Dictionary) virtual const 🔗

Generate a preview directly from a path with the specified size. Implementing this is optional, as default code will load and call _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 EditorResourceTooltipPlugin._make_tooltip_for_path() (like image size, sample length etc.).


bool _generate_small_preview_automatically() virtual const 🔗

如果該函式返回 true,則該生成器將自動從通過方法 _generate()_generate_from_path() 生成的普通預覽紋理生成小型預覽。

預設情況下,它返回 false


bool _handles(type: String) virtual required const 🔗

如果你的生成器支援型別為 type 的資源,則返回 true


void request_draw_and_wait(viewport: RID) const 🔗

Call from within _generate() to request the rendering server draw to the viewport.