EditorResourceTooltipPlugin

继承: RefCounted < Object

A plugin that advanced tooltip for its handled resource type.

描述

Resource tooltip plugins are used by FileSystemDock to generate customized tooltips for specific resources. E.g. tooltip for a Texture2D displays a bigger preview and the texture's dimensions.

A plugin must be first registered with FileSystemDock.add_resource_tooltip_plugin. When the user hovers a resource in filesystem dock which is handled by the plugin, _make_tooltip_for_path is called to create the tooltip. It works similarly to Control._make_custom_tooltip.

方法

bool_handles ( type: String ) virtual1 const2
Control_make_tooltip_for_path ( path: String, metadata: Dictionary, base: Control ) virtual1 const2
voidrequest_thumbnail ( path: String, control: TextureRect ) const2

方法说明

bool _handles ( type: String ) virtual1 const2

Return true if the plugin is going to handle the given Resource type.


Control _make_tooltip_for_path ( path: String, metadata: Dictionary, base: Control ) virtual1 const2

Create and return a tooltip that will be displayed when the user hovers a resource under the given path in filesystem dock.

The metadata dictionary is provided by preview generator (see EditorResourcePreviewGenerator._generate).

base is the base default tooltip, which is a VBoxContainer with a file name, type and size labels. If another plugin handled the same file type, base will be output from the previous plugin. For best result, make sure the base tooltip is part of the returned Control.

Note: It's unadvised to use ResourceLoader.load, especially with heavy resources like models or textures, because it will make the editor unresponsive when creating the tooltip. You can use request_thumbnail if you want to display a preview in your tooltip.

Note: If you decide to discard the base, make sure to call Node.queue_free, because it's not freed automatically.


    func _make_tooltip_for_path(path, metadata, base):
        var t_rect = TextureRect.new()
        request_thumbnail(path, t_rect)
        base.add_child(t_rect) # The TextureRect will appear at the bottom of the tooltip.
        return base

void request_thumbnail ( path: String, control: TextureRect ) const2

Requests a thumbnail for the given TextureRect. The thumbnail is created asynchronously by EditorResourcePreview and automatically set when available.

1

本方法通常需要用户覆盖才能生效。

2

本方法无副作用,不会修改该实例的任何成员变量。

3

本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。

4

本方法用于构造某个类型。

5

调用本方法无需实例,可直接使用类名进行调用。

6

本方法描述的是使用本类型作为左操作数的有效运算符。

7

这个值是由下列位标志构成位掩码的整数。

8

无返回值。