fix: freeze on stop

develop
paring 2022-11-04 22:29:12 +09:00
parent c98e1400a2
commit 82ecaea730
7 changed files with 146 additions and 13 deletions

View File

@ -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()

View File

@ -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();
}
}

Binary file not shown.

View File

@ -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:

View File

@ -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:

Binary file not shown.

View File

@ -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: