diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index f5911275c9b..6c1c8b87efe 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -850,7 +850,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { to_reload.push_back(script); if (script->get_path().empty()) { - script->tied_class_name_for_reload = script->script_class->get_name(); + script->tied_class_name_for_reload = script->script_class->get_name_for_lookup(); script->tied_class_namespace_for_reload = script->script_class->get_namespace(); } diff --git a/modules/mono/mono_gd/gd_mono_class.cpp b/modules/mono/mono_gd/gd_mono_class.cpp index 2c65f7e3a0f..9dabb4ec4c6 100644 --- a/modules/mono/mono_gd/gd_mono_class.cpp +++ b/modules/mono/mono_gd/gd_mono_class.cpp @@ -79,12 +79,26 @@ bool GDMonoClass::is_assignable_from(GDMonoClass *p_from) const { return mono_class_is_assignable_from(mono_class, p_from->mono_class); } -GDMonoClass *GDMonoClass::get_parent_class() { +StringName GDMonoClass::get_namespace() const { + GDMonoClass *nesting_class = get_nesting_class(); + if (!nesting_class) + return namespace_name; + return nesting_class->get_namespace(); +} + +String GDMonoClass::get_name_for_lookup() const { + GDMonoClass *nesting_class = get_nesting_class(); + if (!nesting_class) + return class_name; + return nesting_class->get_name_for_lookup() + "/" + class_name; +} + +GDMonoClass *GDMonoClass::get_parent_class() const { MonoClass *parent_mono_class = mono_class_get_parent(mono_class); return parent_mono_class ? GDMono::get_singleton()->get_class(parent_mono_class) : nullptr; } -GDMonoClass *GDMonoClass::get_nesting_class() { +GDMonoClass *GDMonoClass::get_nesting_class() const { MonoClass *nesting_type = mono_class_get_nesting_type(mono_class); return nesting_type ? GDMono::get_singleton()->get_class(nesting_type) : nullptr; } diff --git a/modules/mono/mono_gd/gd_mono_class.h b/modules/mono/mono_gd/gd_mono_class.h index 9237aae0574..44b146b87cb 100644 --- a/modules/mono/mono_gd/gd_mono_class.h +++ b/modules/mono/mono_gd/gd_mono_class.h @@ -113,14 +113,15 @@ public: bool is_assignable_from(GDMonoClass *p_from) const; - _FORCE_INLINE_ StringName get_namespace() const { return namespace_name; } + StringName get_namespace() const; _FORCE_INLINE_ StringName get_name() const { return class_name; } + String get_name_for_lookup() const; _FORCE_INLINE_ MonoClass *get_mono_ptr() const { return mono_class; } _FORCE_INLINE_ const GDMonoAssembly *get_assembly() const { return assembly; } - GDMonoClass *get_parent_class(); - GDMonoClass *get_nesting_class(); + GDMonoClass *get_parent_class() const; + GDMonoClass *get_nesting_class() const; #ifdef TOOLS_ENABLED Vector get_enum_fields();