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 : Node { }
修正方式
要修正此規則的違規情形,請於型別宣告中加上 partial 關鍵字。
什麼時候應該忽略警告
請勿忽略此規則的警告。繼承自 GodotObject 卻未宣告為 partial 的型別,無法由原始碼產生器增強,將導致執行階段錯誤。