From 747cf9e7a7af87a3c451b227ffc25826d2b53d2f Mon Sep 17 00:00:00 2001 From: mechPenSketch Date: Thu, 27 Feb 2025 14:46:58 +0800 Subject: [PATCH] Limit Annotation to Resource --- modules/gdscript/gdscript_parser.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 449b364a5e8..9364e9d70e8 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -4526,6 +4526,13 @@ bool GDScriptParser::export_annotations(AnnotationNode *p_annotation, Node *p_ta if (export_type.builtin_type == Variant::DICTIONARY) { variable->export_info.type = Variant::DICTIONARY; } + } else if (p_annotation->name == SNAME("@export_from_dir")) { + use_default_variable_type_check = false; + + if (!ClassDB::is_parent_class(export_type.native_type, SNAME("Resource"))) { + push_error(R"(Export type can only be a resource.)", p_annotation); + return false; + } } else if (p_annotation->name == SNAME("@export")) { use_default_variable_type_check = false;