Initialize ScriptingService earlier

This commit is contained in:
2023-08-11 17:09:38 +03:00
parent 9e8865bd12
commit 983c22a3a6
8 changed files with 24 additions and 28 deletions

View File

@@ -1006,7 +1006,7 @@ namespace FlaxEngine.Interop
}
[UnmanagedCallersOnly]
internal static void ReloadScriptingAssemblyLoadContext()
internal static void LoadScriptingAssemblyLoadContext()
{
#if FLAX_EDITOR
// Clear all caches which might hold references to assemblies in collectible ALC
@@ -1030,16 +1030,18 @@ namespace FlaxEngine.Interop
FlaxEngine.Json.JsonSerializer.ResetCache();
// Unload the ALC
bool unloading = true;
scriptingAssemblyLoadContext.Unloading += (alc) => { unloading = false; };
scriptingAssemblyLoadContext.Unload();
while (unloading)
System.Threading.Thread.Sleep(1);
if (scriptingAssemblyLoadContext != null)
{
bool unloading = true;
scriptingAssemblyLoadContext.Unloading += (alc) => { unloading = false; };
scriptingAssemblyLoadContext.Unload();
while (unloading)
System.Threading.Thread.Sleep(1);
}
#endif
InitScriptingAssemblyLoadContext();
DelegateHelpers.InitMethods();
#endif
}
[UnmanagedCallersOnly]

View File

@@ -92,8 +92,6 @@ namespace FlaxEngine.Interop
System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
System.Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;
InitScriptingAssemblyLoadContext();
DelegateHelpers.InitMethods();
}
#if FLAX_EDITOR