feat: toggle focus
parent
fa2caf2261
commit
26974a5f26
|
@ -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;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue