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.

GD0301: 일반 유형 인수는 Variant 호환 유형이어야 합니다.

규칙 ID

GD0301

카테고리

사용례

수정 내용이 중단되거나 중단되지 않음

굽기

기본적으로 활성화됨

es

원인

:ref:`Variant 호환 유형 <c_sharp_variant_ Compatible_types>`이 필요한 경우 일반 유형 인수에 지원되지 않는 유형이 지정되었습니다.

설명

일반 유형 매개변수에 [MustBeVariant] 속성으로 주석이 달린 경우 일반 유형은 Variant 호환 유형이어야 합니다. 예를 들어 일반 Godot.Collections.Array<T> 유형은 Variant로 변환할 수 있는 유형의 항목만 지원합니다.

class SomeType { }

// SomeType is not a valid type because it doesn't derive from GodotObject,
// so it's not compatible with Variant.
var invalidArray = new Godot.Collections.Array<SomeType>();

// System.Int32 is a valid type because it's compatible with Variant.
var validArray = new Godot.Collections.Array<int>();

독립적으로 존재해야 하는 것

이 규칙 위반 문제를 해결하려면 일반 형식 인수를 Variant 호환 형식으로 변경하거나 일반 형식 인수가 Variant 호환 형식이 되도록 요구하지 않는 다른 API를 사용하세요.

경고를 억제해야 하는 경우

이 규칙에서 경고를 표시하지 마세요. [MustBeVariant] 속성으로 주석이 달린 일반 유형 인수를 포함하는 API에는 일반적으로 값이 엔진에 전달되기 때문에 이 요구 사항이 있습니다. 유형을 마샬링할 수 없으면 런타임 오류가 발생합니다.