diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 8e1587997b9..30079f62a7e 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -2867,8 +2867,11 @@ Ref ResourceFormatLoaderCSharpScript::load(const String &p_path, const ERR_FAIL_COND_V_MSG(err != OK, Ref(), "Cannot load C# script file '" + p_path + "'."); #endif - scr->set_path(p_original_path); + // Only one instance of a C# script is allowed to exist. + ERR_FAIL_COND_V_MSG(!scr->get_path().is_empty() && scr->get_path() != p_original_path, Ref(), + "The C# script path is different from the path it was registered in the C# dictionary."); + scr->set_path(p_original_path, true); scr->reload(); if (r_error) {