Godot Engine – Multi-platform 2D and 3D game engine
[.NET] Update exports when the script path changes
Raul Santoscb8f3a4b7d10
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cppindex e0c4a2bcb5d..369f262d855 100644--- a/modules/mono/csharp_script.cpp+++ b/modules/mono/csharp_script.cpp@@ -2349,6 +2349,14 @@ void CSharpScript::_get_property_list(List<PropertyInfo> *p_properties) const {p_properties->push_back(PropertyInfo(Variant::STRING, SNAME("script/source"), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL));}+#ifdef TOOLS_ENABLED+void CSharpScript::_resource_path_changed() {+ // If the script changed its path, update the exports.+ exports_invalidated = true;+ _update_exports();+}+#endif+void CSharpScript::_bind_methods() {ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "new", &CSharpScript::_new, MethodInfo("new"));}diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.hindex 3a51760afed..f5e407924cf 100644--- a/modules/mono/csharp_script.h+++ b/modules/mono/csharp_script.h@@ -286,6 +286,10 @@ protected:bool _set(const StringName &p_name, const Variant &p_value);void _get_property_list(List<PropertyInfo> *p_properties) const;+#ifdef TOOLS_ENABLED+ virtual void _resource_path_changed() override;+#endif+public:static void reload_registered_script(Ref<CSharpScript> p_script);