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.
Checking the stable version of the documentation...
GD0001:从 GodotObject 派生的类型声明中缺少 partial 修饰符
规则 ID |
GD0001 |
类别 |
用法 |
修复是破坏性的还是非破坏性的 |
非破坏性的 |
默认启用 |
是 |
原因
从 GodotObject
派生的类型未被声明为 partial。
规则说明
Godot 源生成器将生成的代码添加到用户定义的类型以实现与引擎的集成。源生成器无法将生成的代码添加到未声明为 partial 的类型。
// The source generators can't enhance this type to work with Godot.
public class InvalidNode : Node { }
// The source generators can enhance this type to work with Godot.
public partial class ValidNode { }
如何解决违规情况
要修复违反该规则的情况,请将 partial
关键字添加到类型声明中。
何时抑制警告
不要抑制该规则的警告。从 GodotObject
派生但不是 partial 的类型无法通过源生成器进行增强,从而导致意外的运行时错误。