Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

GD0102: The type of the exported member is not supported

规则 ID

GD0102

类别

用法

修复是中断修复还是非中断修复

Breaking - If the member type is changed

Non-breaking - If the [Export] attribute is removed

默认启用

原因

An unsupported type is specified for a member annotated with the [Export] attribute when a Variant-compatible type is expected.

规则说明

Every exported member must be Variant-compatible so it can be marshalled by the engine.

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; }

如何解决冲突

To fix a violation of this rule, change the member's type to be Variant-compatible or remove the [Export] attribute.

何时禁止显示警告

Do not suppress a warning from this rule. Members with types that can't be marshalled will result in runtime errors.