feat: toggle focus

develop
ChocoSwi 2022-11-05 23:38:03 +09:00
parent fa2caf2261
commit 26974a5f26
2 changed files with 10 additions and 3 deletions

View File

@ -17,6 +17,11 @@ namespace SkyHook.Editor
GUI.enabled = true; GUI.enabled = true;
manager.requireFocus = EditorGUILayout.Toggle("Require Focus", manager.requireFocus); manager.requireFocus = EditorGUILayout.Toggle("Require Focus", manager.requireFocus);
GUI.enabled = manager.requireFocus;
SkyHookManager.isFocused = EditorGUILayout.Toggle("Focus", SkyHookManager.isFocused);
GUI.enabled = true;
} }
} }
} }

View File

@ -10,7 +10,7 @@ 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.
@ -49,7 +49,7 @@ namespace SkyHook
private void HookCallback(SkyHookEvent ev) private void HookCallback(SkyHookEvent ev)
{ {
if (requireFocus && !_isFocused) if (requireFocus && !isFocused)
{ {
return; return;
} }
@ -124,7 +124,9 @@ namespace SkyHook
{ {
if (requireFocus) if (requireFocus)
{ {
_isFocused = Application.isFocused; #if !UNITY_EDITOR
isFocused = Application.isFocused;
#endif
} }
} }
} }