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.

GD0101:导出成员是静态的

规则 ID

GD0101

类别

用法

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

破坏性的 - 如果 static 关键字被移除

非破坏性的 - 如果 [Export] 属性被移除

默认启用

原因

静态成员使用 [Export] 属性进行注解。静态成员无法被导出。

规则说明

Godot 不允许导出静态成员。

// Static members can't be exported.
[Export]
public static int InvalidProperty { get; set; }

// Instance members can be exported.
[Export]
public int ValidProperty { get; set; }

如何解决违规情况

要修复违反该规则的情况,请移除 [Export] 属性或移除 static 关键字。

何时抑制警告

不要抑制该规则的警告。静态成员无法被导出,因此它们将被 Godot 忽略,从而导致运行时错误。