Compare commits
	
		
			No commits in common. "26974a5f263027590a3dfda9056363f59665da96" and "dfdab317808abdfa6cc3e10aec937dcc2b7c1360" have entirely different histories. 
		
	
	
		
			26974a5f26
			...
			dfdab31780
		
	
		| 
						 | 
					@ -1,8 +0,0 @@
 | 
				
			||||||
fileFormatVersion: 2
 | 
					 | 
				
			||||||
guid: cff19c4bbf3d41b19e1153313bdf1711
 | 
					 | 
				
			||||||
folderAsset: yes
 | 
					 | 
				
			||||||
DefaultImporter:
 | 
					 | 
				
			||||||
  externalObjects: {}
 | 
					 | 
				
			||||||
  userData: 
 | 
					 | 
				
			||||||
  assetBundleName: 
 | 
					 | 
				
			||||||
  assetBundleVariant: 
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,18 +0,0 @@
 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    "name": "SkyHook.Unity.Editor",
 | 
					 | 
				
			||||||
    "rootNamespace": "SkyHook.Editor",
 | 
					 | 
				
			||||||
    "references": [
 | 
					 | 
				
			||||||
        "GUID:5277a9c527b33a210bfa8bb54a667bf4"
 | 
					 | 
				
			||||||
    ],
 | 
					 | 
				
			||||||
    "includePlatforms": [
 | 
					 | 
				
			||||||
        "Editor"
 | 
					 | 
				
			||||||
    ],
 | 
					 | 
				
			||||||
    "excludePlatforms": [],
 | 
					 | 
				
			||||||
    "allowUnsafeCode": false,
 | 
					 | 
				
			||||||
    "overrideReferences": false,
 | 
					 | 
				
			||||||
    "precompiledReferences": [],
 | 
					 | 
				
			||||||
    "autoReferenced": true,
 | 
					 | 
				
			||||||
    "defineConstraints": [],
 | 
					 | 
				
			||||||
    "versionDefines": [],
 | 
					 | 
				
			||||||
    "noEngineReferences": false
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,7 +0,0 @@
 | 
				
			||||||
fileFormatVersion: 2
 | 
					 | 
				
			||||||
guid: e98a4443e126cb545b34b0b136664543
 | 
					 | 
				
			||||||
AssemblyDefinitionImporter:
 | 
					 | 
				
			||||||
  externalObjects: {}
 | 
					 | 
				
			||||||
  userData: 
 | 
					 | 
				
			||||||
  assetBundleName: 
 | 
					 | 
				
			||||||
  assetBundleVariant: 
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,27 +0,0 @@
 | 
				
			||||||
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;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,11 +0,0 @@
 | 
				
			||||||
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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static bool isFocused;
 | 
					        private 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 bool requireFocus = true;
 | 
					        public static bool RequireFocus = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public bool isHookActive;
 | 
					        private bool _started;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <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 (isHookActive) return;
 | 
					                if (_started) 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);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                isHookActive = true;
 | 
					                _started = true;
 | 
				
			||||||
                started = true;
 | 
					                started = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                while (isHookActive)
 | 
					                while (_started)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }).Start();
 | 
					            }).Start();
 | 
				
			||||||
| 
						 | 
					@ -93,7 +93,7 @@ namespace SkyHook
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private void _StopHook()
 | 
					        private void _StopHook()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (!isHookActive) return;
 | 
					            if (!_started) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var result = SkyHookNative.StopHook();
 | 
					            var result = SkyHookNative.StopHook();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -102,7 +102,7 @@ namespace SkyHook
 | 
				
			||||||
                throw new SkyHookException(result);
 | 
					                throw new SkyHookException(result);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            isHookActive = false;
 | 
					            _started = false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static void StartHook()
 | 
					        public static void StartHook()
 | 
				
			||||||
| 
						 | 
					@ -122,11 +122,9 @@ namespace SkyHook
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private void Update()
 | 
					        private void Update()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (requireFocus)
 | 
					            if (RequireFocus)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                #if !UNITY_EDITOR
 | 
					                _isFocused = Application.isFocused;
 | 
				
			||||||
                isFocused = Application.isFocused;
 | 
					 | 
				
			||||||
                #endif
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Reference in New Issue