Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

EditorResourcePreviewGenerator

Inherits: RefCounted < Object

Custom generator of previews.

Description

Custom code to generate previews. Please check file_dialog/thumbnail_size in EditorSettings to find out the right size to do previews at.

Methods

bool

_can_generate_small_preview ( ) virtual const

Texture2D

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

Texture2D

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

bool

_generate_small_preview_automatically ( ) virtual const

bool

_handles ( String type ) virtual const


Method Descriptions

bool _can_generate_small_preview ( ) virtual const

If this function returns true, the generator will call _generate or _generate_from_path for small previews as well.

By default, it returns false.


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

Generate a preview from a given resource with the specified size. This must always be implemented.

Returning an empty texture 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 ( String path, Vector2i size, Dictionary metadata ) 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 an empty texture 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

If this function returns true, the generator will automatically generate the small previews from the normal preview texture generated by the methods _generate or _generate_from_path.

By default, it returns false.


bool _handles ( String type ) virtual const

Returns true if your generator supports the resource of type type.