summaryrefslogtreecommitdiff
path: root/modules/gdscript/gdscript_parser.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-10-31 11:11:07 +0100
committerRémi Verschelde <rverschelde@gmail.com>2022-10-31 11:11:07 +0100
commitf4f98c4ecb02d1670b5be049858bc8182f1163fd (patch)
tree41927d17d26f135b3245b94b9ebacc4796753332 /modules/gdscript/gdscript_parser.cpp
parent87545bf8739121d054489d5228f195885ff80a00 (diff)
parent5d06843fcfe8a7c620ee3b31b82edc930433ad81 (diff)
Merge pull request #67055 from GuilhermeGSousa/custom-node-export
Added custom node export
Diffstat (limited to 'modules/gdscript/gdscript_parser.cpp')
-rw-r--r--modules/gdscript/gdscript_parser.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index bdf6fb35b6..4279edf394 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -3765,13 +3765,19 @@ bool GDScriptParser::export_annotations(const AnnotationNode *p_annotation, Node
break;
case GDScriptParser::DataType::CLASS:
// Can assume type is a global GDScript class.
- if (!ClassDB::is_parent_class(export_type.native_type, SNAME("Resource"))) {
- push_error(R"(Exported script type must extend Resource.)");
+ if (ClassDB::is_parent_class(export_type.native_type, SNAME("Resource"))) {
+ variable->export_info.type = Variant::OBJECT;
+ variable->export_info.hint = PROPERTY_HINT_RESOURCE_TYPE;
+ variable->export_info.hint_string = export_type.class_type->identifier->name;
+ } else if (ClassDB::is_parent_class(export_type.native_type, SNAME("Node"))) {
+ variable->export_info.type = Variant::OBJECT;
+ variable->export_info.hint = PROPERTY_HINT_NODE_TYPE;
+ variable->export_info.hint_string = export_type.class_type->identifier->name;
+ } else {
+ push_error(R"(Export type can only be built-in, a resource, a node or an enum.)", variable);
return false;
}
- variable->export_info.type = Variant::OBJECT;
- variable->export_info.hint = PROPERTY_HINT_RESOURCE_TYPE;
- variable->export_info.hint_string = export_type.class_type->identifier->name;
+
break;
case GDScriptParser::DataType::SCRIPT: {
StringName class_name;