diff --git a/Runtime/SkyHookManager.cs b/Runtime/SkyHookManager.cs index 7e03eb3..9368538 100644 --- a/Runtime/SkyHookManager.cs +++ b/Runtime/SkyHookManager.cs @@ -40,6 +40,8 @@ namespace SkyHook // ReSharper disable once MemberCanBePrivate.Global public static readonly UnityEvent KeyUpdated = new(); + private SkyHookNative.Callback _callback; + /// /// The instance of . /// A new instance will be created if it does not exist. @@ -85,24 +87,32 @@ namespace SkyHook { try { - var result = SkyHookNative.StartHook(HookCallback); + _callback = HookCallback; + var result = SkyHookNative.StartHook(_callback); + if (result != null) { exception = new SkyHookException(result); } - + isHookActive = true; started = true; - + _mre.WaitOne(); + + Debug.Log("Thread ended"); } catch (Exception e) { exception = e; + Debug.LogError(e); throw; } }).Start(); + + isHookActive = true; + started = true; while (!started && exception == null) { diff --git a/Runtime/SkyHookNative.cs b/Runtime/SkyHookNative.cs index 59b3a87..4032032 100644 --- a/Runtime/SkyHookNative.cs +++ b/Runtime/SkyHookNative.cs @@ -10,6 +10,7 @@ namespace SkyHook /// /// The native callback handled by . /// + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void Callback(SkyHookEvent ev); private const string Lib = "skyhook";