1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-10 13:00:37 +00:00

Merge pull request #87838 from paulloz/dotnet/fix-duplicate-key-on-reload

C#: Fix duplicate key issue on reload
This commit is contained in:
Rémi Verschelde
2024-02-02 12:05:14 +01:00
2 changed files with 12 additions and 7 deletions

View File

@@ -310,13 +310,6 @@ namespace Godot.Bridge
_pathTypeBiMap.Add(scriptPathAttr.Path, 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) if (AlcReloadCfg.IsAlcReloadingEnabled)
{ {
AddTypeForAlcReloading(type); AddTypeForAlcReloading(type);
@@ -366,6 +359,16 @@ namespace Godot.Bridge
} }
} }
} }
// 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] [UnmanagedCallersOnly]

View File

@@ -61,6 +61,8 @@ public static partial class ScriptManagerBridge
private System.Collections.Generic.Dictionary<string, Type> _pathTypeMap = new(); private System.Collections.Generic.Dictionary<string, Type> _pathTypeMap = new();
private System.Collections.Generic.Dictionary<Type, string> _typePathMap = 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) public void Add(string scriptPath, Type scriptType)
{ {
_pathTypeMap.Add(scriptPath, scriptType); _pathTypeMap.Add(scriptPath, scriptType);