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.