mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Merge pull request #89324 from KoBeWi/pandora's_can_of_worms
Allow exporting variables of type Variant
This commit is contained in:
commit
c87f23ce7d
5 changed files with 127 additions and 12 deletions
|
@ -4568,14 +4568,9 @@ bool GDScriptParser::export_annotations(AnnotationNode *p_annotation, Node *p_ta
|
|||
return false;
|
||||
}
|
||||
|
||||
if (export_type.is_variant() || export_type.has_no_type()) {
|
||||
if (is_dict) {
|
||||
// Dictionary allowed to have a variant key/value.
|
||||
export_type.kind = GDScriptParser::DataType::BUILTIN;
|
||||
} else {
|
||||
push_error(R"(Cannot use simple "@export" annotation because the type of the initialized value can't be inferred.)", p_annotation);
|
||||
return false;
|
||||
}
|
||||
if (export_type.has_no_type()) {
|
||||
push_error(R"(Cannot use simple "@export" annotation because the type of the initialized value can't be inferred.)", p_annotation);
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (export_type.kind) {
|
||||
|
@ -4626,6 +4621,12 @@ bool GDScriptParser::export_annotations(AnnotationNode *p_annotation, Node *p_ta
|
|||
variable->export_info.class_name = String(export_type.native_type).replace("::", ".");
|
||||
}
|
||||
} break;
|
||||
case GDScriptParser::DataType::VARIANT: {
|
||||
if (export_type.is_variant()) {
|
||||
variable->export_info.type = Variant::NIL;
|
||||
variable->export_info.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
push_error(R"(Export type can only be built-in, a resource, a node, or an enum.)", p_annotation);
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue