Merge pull request #65046 from neikeq/dotnet-fix-exported-game-uninitialized-callbacks

C#: Fix exported game crash because of uninitialized callbacks
This commit is contained in:
Ignacio Roldán Etcheverry 2022-08-29 18:14:04 +02:00 committed by GitHub
commit a5218989a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,7 +27,8 @@ namespace GodotPlugins.Game
internal static partial class Main internal static partial class Main
{ {
[UnmanagedCallersOnly(EntryPoint = ""godotsharp_game_main_init"")] [UnmanagedCallersOnly(EntryPoint = ""godotsharp_game_main_init"")]
private static godot_bool InitializeFromGameProject(IntPtr godotDllHandle, IntPtr outManagedCallbacks) private static godot_bool InitializeFromGameProject(IntPtr godotDllHandle, IntPtr outManagedCallbacks,
IntPtr unmanagedCallbacks, int unmanagedCallbacksSize)
{ {
try try
{ {
@ -37,6 +38,8 @@ namespace GodotPlugins.Game
NativeLibrary.SetDllImportResolver(coreApiAssembly, dllImportResolver); NativeLibrary.SetDllImportResolver(coreApiAssembly, dllImportResolver);
NativeFuncs.Initialize(unmanagedCallbacks, unmanagedCallbacksSize);
ManagedCallbacks.Create(outManagedCallbacks); ManagedCallbacks.Create(outManagedCallbacks);
ScriptManagerBridge.LookupScriptsInAssembly(typeof(GodotPlugins.Game.Main).Assembly); ScriptManagerBridge.LookupScriptsInAssembly(typeof(GodotPlugins.Game.Main).Assembly);