diff --git a/Runtime/SkyHookManager.cs b/Runtime/SkyHookManager.cs index 28cf5b7..6a2862b 100644 --- a/Runtime/SkyHookManager.cs +++ b/Runtime/SkyHookManager.cs @@ -1,3 +1,6 @@ +using System; +using System.Threading; +using System.Threading.Tasks; using UnityEngine; using UnityEngine.Events; @@ -54,8 +57,10 @@ namespace SkyHook KeyUpdated.Invoke(ev); } - private void StartHook() + private void _StartHook() { + if (_started) return; + var result = SkyHookNative.StartHook(HookCallback); if (result != null) @@ -66,7 +71,7 @@ namespace SkyHook _started = true; } - private void StopHook() + private void _StopHook() { if (!_started) return; @@ -78,22 +83,23 @@ namespace SkyHook } _started = false; + + _started = false; } - public static void Start() + public static void StartHook() { - Instance.StartHook(); + Instance._StartHook(); } - public static void Stop() + public static void StopHook() { - Instance.StopHook(); + Instance._StopHook(); } private void OnDestroy() { - Debug.Log("Destroy"); - StopHook(); + _StopHook(); } private void Update() diff --git a/Runtime/SkyHookNative.cs b/Runtime/SkyHookNative.cs index 0652a5a..347571b 100644 --- a/Runtime/SkyHookNative.cs +++ b/Runtime/SkyHookNative.cs @@ -2,16 +2,16 @@ using System.Runtime.InteropServices; namespace SkyHook { - internal class SkyHookNative + internal static class SkyHookNative { public delegate void Callback(SkyHookEvent ev); - private const string LIB = "skyhook"; + private const string Lib = "skyhook"; - [DllImport(LIB, EntryPoint = "start_hook", CallingConvention = CallingConvention.Cdecl)] + [DllImport(Lib, EntryPoint = "start_hook", CallingConvention = CallingConvention.Cdecl)] public static extern string StartHook(Callback callback); - [DllImport(LIB, EntryPoint = "stop_hook", CallingConvention = CallingConvention.Cdecl)] + [DllImport(Lib, EntryPoint = "stop_hook", CallingConvention = CallingConvention.Cdecl)] public static extern string StopHook(); } } \ No newline at end of file diff --git a/plugins/aarch64/libskyhook.dylib b/plugins/aarch64/libskyhook.dylib index 4894831..609a4b6 100755 Binary files a/plugins/aarch64/libskyhook.dylib and b/plugins/aarch64/libskyhook.dylib differ diff --git a/plugins/aarch64/libskyhook.dylib.meta b/plugins/aarch64/libskyhook.dylib.meta index 0e1f0a5..db088c3 100644 --- a/plugins/aarch64/libskyhook.dylib.meta +++ b/plugins/aarch64/libskyhook.dylib.meta @@ -11,6 +11,17 @@ PluginImporter: isExplicitlyReferenced: 0 validateReferences: 1 platformData: + - first: + : Any + second: + enabled: 0 + settings: + Exclude Editor: 0 + Exclude Linux64: 1 + Exclude OSXUniversal: 0 + Exclude WebGL: 1 + Exclude Win: 1 + Exclude Win64: 1 - first: Any: second: @@ -21,13 +32,33 @@ PluginImporter: second: enabled: 1 settings: + CPU: ARM64 DefaultValueInitialized: true + OS: OSX + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 - first: Standalone: OSXUniversal second: enabled: 1 settings: - CPU: AnyCPU + CPU: ARM64 + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: x86 + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: x86_64 userData: assetBundleName: assetBundleVariant: diff --git a/plugins/i686/skyhook.dll.meta b/plugins/i686/skyhook.dll.meta new file mode 100644 index 0000000..355516c --- /dev/null +++ b/plugins/i686/skyhook.dll.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: a9d394d2428104e008ccad309aac73a6 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 1 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/plugins/x86_64/libskyhook.dylib b/plugins/x86_64/libskyhook.dylib index 039e5ab..f0f93b5 100755 Binary files a/plugins/x86_64/libskyhook.dylib and b/plugins/x86_64/libskyhook.dylib differ diff --git a/plugins/x86_64/libskyhook.dylib.meta b/plugins/x86_64/libskyhook.dylib.meta new file mode 100644 index 0000000..e890b27 --- /dev/null +++ b/plugins/x86_64/libskyhook.dylib.meta @@ -0,0 +1,69 @@ +fileFormatVersion: 2 +guid: 64e8137adce094429a9428464a954f6a +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 1 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + : Any + second: + enabled: 0 + settings: + Exclude Editor: 0 + Exclude Linux64: 0 + Exclude OSXUniversal: 0 + Exclude WebGL: 0 + Exclude Win: 0 + Exclude Win64: 0 + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + CPU: x86_64 + DefaultValueInitialized: true + OS: OSX + - first: + Standalone: Linux64 + second: + enabled: 1 + settings: + CPU: AnyCPU + - first: + Standalone: OSXUniversal + second: + enabled: 1 + settings: + CPU: x86_64 + - first: + Standalone: Win + second: + enabled: 1 + settings: + CPU: None + - first: + Standalone: Win64 + second: + enabled: 1 + settings: + CPU: x86_64 + - first: + WebGL: WebGL + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: