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...
GD0401: The class must derive from Godot.GodotObject or a derived class¶
规则 ID |
GD0401 |
类别 |
用法 |
修复是中断修复还是非中断修复 |
Breaking - If changing the inheritance chain Non-breaking - If removing the |
默认启用 |
是 |
原因¶
A type annotated with the [GlobalClass] attribute does not derive from
GodotObject.
规则说明¶
The [GlobalClass] has no effect for types that don't derive from GodotObject.
Every global class must ultimately derive from
GodotObject so it can be marshalled.
// This type is not registered as a global class because it doesn't derive from GodotObject.
[GlobalClass]
class SomeType { }
// This type is a global class because it derives from Godot.Node
// which ultimately derives from GodotObject.
[GlobalClass]
class MyNode : Node { }
// This type is a global class because it derives from Godot.Resource
// which ultimately derives from GodotObject.
[GlobalClass]
class MyResource : Resource { }
如何解决冲突¶
To fix a violation of this rule, change the type to derive from GodotObject
or remove the [GlobalClass] attribute.
何时禁止显示警告¶
Do not suppress a warning from this rule. Adding the [GlobalClass] to a type
that doesn't derive from GodotObject is an easy mistake to make and this
warning helps users realize that it may result in unexpected errors.