Compare commits
7 Commits
dfdab31780
...
26974a5f26
Author | SHA1 | Date |
---|---|---|
ChocoSwi | 26974a5f26 | |
ChocoSwi | fa2caf2261 | |
ChocoSwi | 317967423f | |
ChocoSwi | b55dd298ed | |
ChocoSwi | f13e1e985e | |
ChocoSwi | ddd65f022e | |
ChocoSwi | d53da21bf5 |
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: cff19c4bbf3d41b19e1153313bdf1711
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"name": "SkyHook.Unity.Editor",
|
||||||
|
"rootNamespace": "SkyHook.Editor",
|
||||||
|
"references": [
|
||||||
|
"GUID:5277a9c527b33a210bfa8bb54a667bf4"
|
||||||
|
],
|
||||||
|
"includePlatforms": [
|
||||||
|
"Editor"
|
||||||
|
],
|
||||||
|
"excludePlatforms": [],
|
||||||
|
"allowUnsafeCode": false,
|
||||||
|
"overrideReferences": false,
|
||||||
|
"precompiledReferences": [],
|
||||||
|
"autoReferenced": true,
|
||||||
|
"defineConstraints": [],
|
||||||
|
"versionDefines": [],
|
||||||
|
"noEngineReferences": false
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e98a4443e126cb545b34b0b136664543
|
||||||
|
AssemblyDefinitionImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,27 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace SkyHook.Editor
|
||||||
|
{
|
||||||
|
[CustomEditor(typeof(SkyHookManager))]
|
||||||
|
public class SkyHookEditor : UnityEditor.Editor
|
||||||
|
{
|
||||||
|
public override void OnInspectorGUI()
|
||||||
|
{
|
||||||
|
SkyHookManager manager = (SkyHookManager)target;
|
||||||
|
|
||||||
|
GUI.enabled = false;
|
||||||
|
EditorGUILayout.Toggle("Hook Started", manager.isHookActive);
|
||||||
|
GUI.enabled = true;
|
||||||
|
|
||||||
|
manager.requireFocus = EditorGUILayout.Toggle("Require Focus", manager.requireFocus);
|
||||||
|
|
||||||
|
GUI.enabled = manager.requireFocus;
|
||||||
|
SkyHookManager.isFocused = EditorGUILayout.Toggle("Focus", SkyHookManager.isFocused);
|
||||||
|
GUI.enabled = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 31ad107d386d43df9f3f1921ddde6e65
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -10,16 +10,16 @@ namespace SkyHook
|
||||||
{
|
{
|
||||||
private static SkyHookManager _instance;
|
private static SkyHookManager _instance;
|
||||||
|
|
||||||
private static bool _isFocused;
|
public static bool isFocused;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether or not the event will be received only if the game window is focused.
|
/// Whether or not the event will be received only if the game window is focused.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
// ReSharper disable once MemberCanBePrivate.Global
|
// ReSharper disable once MemberCanBePrivate.Global
|
||||||
// ReSharper disable once FieldCanBeMadeReadOnly.Global
|
// ReSharper disable once FieldCanBeMadeReadOnly.Global
|
||||||
public static bool RequireFocus = true;
|
public bool requireFocus = true;
|
||||||
|
|
||||||
private bool _started;
|
public bool isHookActive;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The key updated event data
|
/// The key updated event data
|
||||||
|
@ -49,7 +49,7 @@ namespace SkyHook
|
||||||
|
|
||||||
private void HookCallback(SkyHookEvent ev)
|
private void HookCallback(SkyHookEvent ev)
|
||||||
{
|
{
|
||||||
if (RequireFocus && !_isFocused)
|
if (requireFocus && !isFocused)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ namespace SkyHook
|
||||||
|
|
||||||
new Thread(() =>
|
new Thread(() =>
|
||||||
{
|
{
|
||||||
if (_started) return;
|
if (isHookActive) return;
|
||||||
|
|
||||||
var result = SkyHookNative.StartHook(HookCallback);
|
var result = SkyHookNative.StartHook(HookCallback);
|
||||||
|
|
||||||
|
@ -73,10 +73,10 @@ namespace SkyHook
|
||||||
exception = new SkyHookException(result);
|
exception = new SkyHookException(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
_started = true;
|
isHookActive = true;
|
||||||
started = true;
|
started = true;
|
||||||
|
|
||||||
while (_started)
|
while (isHookActive)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}).Start();
|
}).Start();
|
||||||
|
@ -93,7 +93,7 @@ namespace SkyHook
|
||||||
|
|
||||||
private void _StopHook()
|
private void _StopHook()
|
||||||
{
|
{
|
||||||
if (!_started) return;
|
if (!isHookActive) return;
|
||||||
|
|
||||||
var result = SkyHookNative.StopHook();
|
var result = SkyHookNative.StopHook();
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ namespace SkyHook
|
||||||
throw new SkyHookException(result);
|
throw new SkyHookException(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
_started = false;
|
isHookActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void StartHook()
|
public static void StartHook()
|
||||||
|
@ -122,9 +122,11 @@ namespace SkyHook
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
if (RequireFocus)
|
if (requireFocus)
|
||||||
{
|
{
|
||||||
_isFocused = Application.isFocused;
|
#if !UNITY_EDITOR
|
||||||
|
isFocused = Application.isFocused;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue