Skip to content

Commit

Permalink
Merge pull request #88692 from nongvantinh/fix-88543
Browse files Browse the repository at this point in the history
Fix Script Editor saves C# files as embedded scripts.
  • Loading branch information
akien-mga committed Feb 26, 2024
2 parents abe73c3 + c5e6a58 commit 5059dd9
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion modules/mono/csharp_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2851,7 +2851,22 @@ Ref<Resource> ResourceFormatLoaderCSharpScript::load(const String &p_path, const
ERR_FAIL_COND_V_MSG(!scr->get_path().is_empty() && scr->get_path() != p_original_path, Ref<Resource>(),
"The C# script path is different from the path it was registered in the C# dictionary.");

scr->set_path(p_original_path, true);
Ref<Resource> existing = ResourceCache::get_ref(p_path);
switch (p_cache_mode) {
case ResourceFormatLoader::CACHE_MODE_IGNORE:
break;
case ResourceFormatLoader::CACHE_MODE_REUSE:
if (existing.is_null()) {
scr->set_path(p_original_path);
} else {
scr = existing;
}
break;
case ResourceFormatLoader::CACHE_MODE_REPLACE:
scr->set_path(p_original_path, true);
break;
}

scr->reload();

if (r_error) {
Expand Down

0 comments on commit 5059dd9

Please sign in to comment.