EditorResourcePreviewGenerator
Custom generator of previews.
Custom generator of previews.
Custom code to generate previews. Check EditorSettings.filesystem/file_dialog/thumbnail_size to find a proper size to generate previews at.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
EditorResourcePreviewGeneratorConstructor
public EditorResourcePreviewGenerator();Methods6
RequestDrawAndWaitvoid
public void RequestDrawAndWait(Rid viewport);Call from within EditorResourcePreviewGenerator._Generate to request the rendering server draw to the viewport.
| Name | Type | Default |
|---|---|---|
viewport | Rid | — |
_CanGenerateSmallPreviewbool
public virtual bool _CanGenerateSmallPreview();If this function returns true, the generator will call EditorResourcePreviewGenerator._Generate or EditorResourcePreviewGenerator._GenerateFromPath for small previews as well.
By default, it returns false.
bool_GenerateTexture2D
public virtual Texture2D _Generate(Resource resource, Vector2I size, Reckfell.Collections.Dictionary metadata);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._MakeTooltipForPath (like image size, sample length etc.).
| Name | Type | Default |
|---|---|---|
resource | Resource | — |
size | Vector2I | — |
metadata | Reckfell.Collections.Dictionary | — |
Texture2D_GenerateFromPathTexture2D
public virtual Texture2D _GenerateFromPath(string path, Vector2I size, Reckfell.Collections.Dictionary metadata);Generate a preview directly from a path with the specified size. Implementing this is optional, as default code will load and call EditorResourcePreviewGenerator._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._MakeTooltipForPath (like image size, sample length etc.).
| Name | Type | Default |
|---|---|---|
path | string | — |
size | Vector2I | — |
metadata | Reckfell.Collections.Dictionary | — |
Texture2D_GenerateSmallPreviewAutomaticallybool
public virtual bool _GenerateSmallPreviewAutomatically();If this function returns true, the generator will automatically generate the small previews from the normal preview texture generated by the methods EditorResourcePreviewGenerator._Generate or EditorResourcePreviewGenerator._GenerateFromPath.
By default, it returns false.
bool_Handlesbool
public virtual bool _Handles(string type);Returns true if your generator supports the resource of type type.
| Name | Type | Default |
|---|---|---|
type | string | — |
bool