-
Notifications
You must be signed in to change notification settings - Fork 328
NEW: Added canRunInBackground flag in device debug view #2013
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
3d5f2a4
8b36040
531215b
0178bc1
4952a6f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -247,14 +247,27 @@ public bool canRunInBackground | |
// In the editor, "background" refers to "game view not focused", not to the editor not being active. | ||
// So, we modulate canRunInBackground depending on how input should behave WRT game view according | ||
// to the input settings. | ||
#if UNITY_EDITOR | ||
#if UNITY_EDITOR | ||
|
||
var gameViewFocus = InputSystem.settings.editorInputBehaviorInPlayMode; | ||
if (gameViewFocus == InputSettings.EditorInputBehaviorInPlayMode.AllDevicesRespectGameViewFocus) | ||
return false; // No device considered being able to run without game view focus. | ||
if (gameViewFocus == InputSettings.EditorInputBehaviorInPlayMode.PointersAndKeyboardsRespectGameViewFocus) | ||
return !(this is Pointer || this is Keyboard); // Anything but pointers and keyboards considered as being able to run in background. | ||
#endif | ||
|
||
|
||
return canDeviceRunInBackground; | ||
} | ||
} | ||
/// <summary> | ||
/// In editor, it may differ from canRunInBackground depending on the gameViewFocus setting. | ||
/// This property is used by Device Debug View | ||
/// </summary> | ||
/// <value>Whether the device should generate input while in the background.</value> | ||
internal bool canDeviceRunInBackground | ||
{ | ||
get | ||
{ | ||
#endif | ||
if ((m_DeviceFlags & DeviceFlags.CanRunInBackgroundHasBeenQueried) != 0) | ||
return (m_DeviceFlags & DeviceFlags.CanRunInBackground) != 0; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2893,22 +2893,8 @@ internal void AddAvailableDevicesThatAreNowRecognized() | |
|
||
private bool ShouldRunDeviceInBackground(InputDevice device) | ||
{ | ||
var runDeviceInBackground = | ||
m_Settings.backgroundBehavior != InputSettings.BackgroundBehavior.ResetAndDisableAllDevices && | ||
return m_Settings.backgroundBehavior != InputSettings.BackgroundBehavior.ResetAndDisableAllDevices && | ||
device.canRunInBackground; | ||
|
||
// In editor, we may override canRunInBackground depending on the gameViewFocus setting. | ||
#if UNITY_EDITOR | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this code is already done in canRunInBackground |
||
if (runDeviceInBackground) | ||
{ | ||
if (m_Settings.editorInputBehaviorInPlayMode == InputSettings.EditorInputBehaviorInPlayMode.AllDevicesRespectGameViewFocus) | ||
runDeviceInBackground = false; | ||
else if (m_Settings.editorInputBehaviorInPlayMode == InputSettings.EditorInputBehaviorInPlayMode.PointersAndKeyboardsRespectGameViewFocus) | ||
runDeviceInBackground = !(device is Pointer || device is Keyboard); | ||
} | ||
#endif | ||
|
||
return runDeviceInBackground; | ||
} | ||
|
||
internal void OnFocusChanged(bool focus) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: Code format
CanRunInBackground