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.

GD0102:被匯出的成員型別不受支援

規則 ID

GD0102

分類

用法

修正是否會破壞相容性

破壞性變更 - 若修改成員型別

非破壞性變更 - 若移除 [Export] 屬性

預設啟用

原因

使用 [Export] 屬性標註的成員,其型別不是預期的 Variant 相容型別

規則說明

每個被匯出的成員都必須是 Variant 相容型別,才能被引擎正確傳遞與處理。

class SomeType { }

// SomeType is not a valid member type because it doesn't derive from GodotObject,
// so it's not compatible with Variant.
[Export]
public SomeType InvalidProperty { get; set; }

// System.Int32 is a valid type because it's compatible with Variant.
[Export]
public int ValidProperty { get; set; }

修正方式

要修正此規則的違規情形,請將成員型別改為 Variant 相容型別,或移除 [Export] 屬性。

什麼時候應該忽略警告

請勿忽略此規則的警告。型別無法被正確傳遞的成員會導致執行階段錯誤。