From 7676e389a77e1b032c81557c067d6a71cdbbf9ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=B4ng=20V=C4=83n=20T=C3=ACnh?= Date: Wed, 29 Nov 2023 18:48:14 +0700 Subject: [PATCH] Fixes C# script loader does not work reliably --- modules/mono/csharp_script.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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) {