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#: Fix duplicate key issue on reload #87838

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,6 @@ static void LookupScriptForClass(Type type)

_pathTypeBiMap.Add(scriptPathAttr.Path, type);

// This method may be called before initialization.
if (NativeFuncs.godotsharp_dotnet_module_is_initialized().ToBool() && Engine.IsEditorHint())
{
using godot_string scriptPath = Marshaling.ConvertStringToNative(scriptPathAttr.Path);
NativeFuncs.godotsharp_internal_editor_file_system_update_file(scriptPath);
}

if (AlcReloadCfg.IsAlcReloadingEnabled)
{
AddTypeForAlcReloading(type);
Expand Down Expand Up @@ -366,6 +359,16 @@ static void LookupScriptForClass(Type type)
}
}
}

// This method may be called before initialization.
if (NativeFuncs.godotsharp_dotnet_module_is_initialized().ToBool() && Engine.IsEditorHint())
{
foreach (var scriptPath in _pathTypeBiMap.Paths)
{
using godot_string nativeScriptPath = Marshaling.ConvertStringToNative(scriptPath);
NativeFuncs.godotsharp_internal_editor_file_system_update_file(nativeScriptPath);
}
}
}

[UnmanagedCallersOnly]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ private class PathScriptTypeBiMap
private System.Collections.Generic.Dictionary<string, Type> _pathTypeMap = new();
private System.Collections.Generic.Dictionary<Type, string> _typePathMap = new();

public System.Collections.Generic.IEnumerable<string> Paths => _pathTypeMap.Keys;

public void Add(string scriptPath, Type scriptType)
{
_pathTypeMap.Add(scriptPath, scriptType);
Expand Down
Loading