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.

GD0108: The exported tool button is not in a tool class

规则 ID

GD0108

类别

用法

修复是破坏性的还是非破坏性的

非破坏性的

默认启用

原因

A property is annotated with the [ExportToolButton] attribute in a class that is not annotated with the [Tool] attribute.

规则说明

The [ExportToolButton] is used to create clickable buttons in the inspector so, like every other script that runs in the editor, it needs to be annotated with the [Tool] attribute.

[Tool]
public partial class MyNode : Node
{
    [ExportToolButton("Click me!")]
    public Callable ClickMeButton => Callable.From(ClickMe);

    private static void ClickMe()
    {
        GD.Print("Hello world!");
    }
}

如何解决违规情况

To fix a violation of this rule, add the [Tool] attribute to the class that contains the member annotated with the [ExportToolButton] attribute.

何时抑制警告

Do not suppress a warning from this rule. The clickable buttons in the inspector won't be functional if their script is not annotated with the [Tool] attribute.