Table of Contents

Class EditorResourcePreviewGenerator

Namespace
Godot
Assembly
GodotSharpEditor.dll

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

public class EditorResourcePreviewGenerator : RefCounted, IDisposable
Inheritance
EditorResourcePreviewGenerator
Implements
Inherited Members

Constructors

EditorResourcePreviewGenerator()

public EditorResourcePreviewGenerator()

Methods

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

_CanGenerateSmallPreview()

If this function returns true, the generator will call _Generate(Resource, Vector2I, Dictionary) or _GenerateFromPath(string, Vector2I, Dictionary) for small previews as well.

By default, it returns false.

public virtual bool _CanGenerateSmallPreview()

Returns

bool

_Generate(Resource, Vector2I, Dictionary)

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 _MakeTooltipForPath(string, Dictionary, Control) (like image size, sample length etc.).

public virtual Texture2D _Generate(Resource resource, Vector2I size, Dictionary metadata)

Parameters

resource Resource
size Vector2I
metadata Dictionary

Returns

Texture2D

_GenerateFromPath(string, Vector2I, Dictionary)

Generate a preview directly from a path with the specified size. Implementing this is optional, as default code will load and call _Generate(Resource, Vector2I, Dictionary).

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 _MakeTooltipForPath(string, Dictionary, Control) (like image size, sample length etc.).

public virtual Texture2D _GenerateFromPath(string path, Vector2I size, Dictionary metadata)

Parameters

path string
size Vector2I
metadata Dictionary

Returns

Texture2D

_GenerateSmallPreviewAutomatically()

If this function returns true, the generator will automatically generate the small previews from the normal preview texture generated by the methods _Generate(Resource, Vector2I, Dictionary) or _GenerateFromPath(string, Vector2I, Dictionary).

By default, it returns false.

public virtual bool _GenerateSmallPreviewAutomatically()

Returns

bool

_Handles(string)

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

public virtual bool _Handles(string type)

Parameters

type string

Returns

bool