@@ -493,6 +493,8 @@ private static unsafe void GetOrCreateScriptBridgeForType(Type scriptType, godot
493493 {
494494 _scriptTypeBiMap . ReadWriteLock . ExitUpgradeableReadLock ( ) ;
495495 }
496+
497+ NativeFuncs . godotsharp_internal_reload_registered_script ( outScript ->Reference ) ;
496498 }
497499
498500 internal static unsafe void GetOrLoadOrCreateScriptForType ( Type scriptType , godot_ref * outScript )
@@ -527,12 +529,14 @@ static bool GetPathOtherwiseGetOrCreateScript(Type scriptType, godot_ref* outScr
527529
528530 CreateScriptBridgeForType ( scriptType , outScript ) ;
529531 scriptPath = null ;
530- return false ;
531532 }
532533 finally
533534 {
534535 _scriptTypeBiMap . ReadWriteLock . ExitUpgradeableReadLock ( ) ;
535536 }
537+
538+ NativeFuncs . godotsharp_internal_reload_registered_script ( outScript ->Reference ) ;
539+ return false ;
536540 }
537541
538542 static string GetVirtualConstructedGenericTypeScriptPath ( Type scriptType , string scriptPath )
@@ -597,6 +601,9 @@ static string GetVirtualConstructedGenericTypeScriptPath(Type scriptType, string
597601 }
598602 }
599603
604+ /// <summary>
605+ /// WARNING: We need to make sure that after unlocking the bimap, we call godotsharp_internal_reload_registered_script
606+ /// </summary>
600607 private static unsafe void CreateScriptBridgeForType ( Type scriptType , godot_ref * outScript )
601608 {
602609 Debug . Assert ( ! scriptType . IsGenericTypeDefinition , $ "Script type must be a constructed generic type or not generic at all. Type: { scriptType } .") ;
@@ -613,8 +620,6 @@ private static unsafe void CreateScriptBridgeForType(Type scriptType, godot_ref*
613620 {
614621 _scriptTypeBiMap . ReadWriteLock . ExitWriteLock ( ) ;
615622 }
616-
617- NativeFuncs . godotsharp_internal_reload_registered_script ( outScript ->Reference ) ;
618623 }
619624
620625 [ UnmanagedCallersOnly ]
0 commit comments