diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.h index 72389cdddcb..0e2b812a221 100644 --- a/modules/gdscript/gdscript.h +++ b/modules/gdscript/gdscript.h @@ -111,6 +111,7 @@ class GDScript : public Script { String source; String path; String name; + String fully_qualified_name; SelfList script_list; GDScriptInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Variant::CallError &r_error); diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index 7b3175d9cd6..711fa54d0b1 100644 --- a/modules/gdscript/gdscript_compiler.cpp +++ b/modules/gdscript/gdscript_compiler.cpp @@ -2131,6 +2131,7 @@ void GDScriptCompiler::_make_scripts(GDScript *p_script, const GDScriptParser::C } subclass->_owner = p_script; + subclass->fully_qualified_name = p_script->fully_qualified_name + "::" + name; p_script->subclasses.insert(name, subclass); _make_scripts(subclass.ptr(), p_class->subclasses[i], false); @@ -2149,6 +2150,9 @@ Error GDScriptCompiler::compile(const GDScriptParser *p_parser, GDScript *p_scri source = p_script->get_path(); + // The best fully qualified name for a base level script is its file path + p_script->fully_qualified_name = p_script->path; + // Create scripts for subclasses beforehand so they can be referenced _make_scripts(p_script, static_cast(root), p_keep_state);