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...
GD0003: Found multiple classes with the same name in the same script file¶
规则 ID |
GD0003 |
类别 |
用法 |
修复是中断修复还是非中断修复 |
Non-breaking |
默认启用 |
是 |
原因¶
A script file contains multiple types that derives from GodotObject with
a name that matches the script file. Only one type in the script file should
match the file name.
规则说明¶
Godot requires scripts to have a unique path so every type must be defined on its own file and the type name must match the file name.
public partial class MyNode : Node { }
namespace DifferentNamespace
{
// Invalid because there's already a type with the name MyNode in this file.
public partial class MyNode : Node { }
}
// Invalid because there's already a type with the name MyNode in this file.
public partial class MyNode<T> : Node { }
如何解决冲突¶
To fix a violation of this rule, move each type declaration to a different file.
何时禁止显示警告¶
Do not suppress a warning from this rule. Types that derive from GodotObject
must have a unique path otherwise the engine can't load the script by path,
resulting in unexpected runtime errors.