Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C# scripts reload in editor fixed #52883

Merged
merged 1 commit into from
Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions modules/mono/csharp_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2708,6 +2708,7 @@ int CSharpScript::_try_get_member_export_hint(IMonoClassMember *p_member, Manage
void CSharpScript::_clear() {
tool = false;
valid = false;
reload_invalidated = true;

base = NULL;
native = NULL;
Expand Down Expand Up @@ -2811,6 +2812,7 @@ void CSharpScript::initialize_for_managed_type(Ref<CSharpScript> p_script, GDMon

p_script->valid = true;
p_script->tool = p_script->script_class->has_attribute(CACHED_CLASS(ToolAttribute));
p_script->reload_invalidated = false;

if (!p_script->tool) {
GDMonoClass *nesting_class = p_script->script_class->get_nesting_class();
Expand Down Expand Up @@ -3117,13 +3119,12 @@ MethodInfo CSharpScript::get_method_info(const StringName &p_method) const {
}

Error CSharpScript::reload(bool p_keep_state) {
bool has_instances;
{
MutexLock lock(CSharpLanguage::get_singleton()->script_instances_mutex);
has_instances = instances.size();
if (!reload_invalidated) {
return OK;
}

ERR_FAIL_COND_V(!p_keep_state && has_instances, ERR_ALREADY_IN_USE);
// In the case of C#, reload doesn't really do any script reloading.
// That's done separately via domain reloading.
reload_invalidated = false;

GD_MONO_SCOPE_THREAD_ATTACH;

Expand Down
1 change: 1 addition & 0 deletions modules/mono/csharp_script.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class CSharpScript : public Script {

bool tool;
bool valid;
bool reload_invalidated;

bool builtin;

Expand Down