Background behavior
Background Behaviour determines what happens when application focus is lost or regained, and how input behaves while the application is not in the foreground.
This setting is only relevant when "Run In Background" is enabled in the Player Settings for the project. This setting is only supported on some platforms. On platforms such as Android and iOS, your app will not run when it is not in the foreground.
In the Editor, "Run In Background" is considered to always be enabled as the player loop is kept running regardless of whether a Game View is focused or not. Also, in development players on desktop platforms, the setting is force-enabled during the build process.
Note
In the editor, Background Behavior is further influenced by Play Mode Input Behavior. Refer to Background and Focus Change Behavior for a detailed breakdown. In particular, which devices are considered as canRunInBackground partly depends on the Play Mode Input Behavior setting.
| Setting | Description |
|---|---|
Reset And Disable Non Background Devices |
When focus is lost, perform a soft reset on all Devices that are not marked as canRunInBackground and also subsequently disable them. Does not affect Devices marked as being able to run in the background.When focus is regained, re-enable any Device that has been disabled and also issue a sync request on these Devices in order to update their current state. If a Device is issued a sync request and does not respond to it, soft-reset the Device. This is the default setting. |
Reset And Disable All Devices |
When focus is lost, perform a soft reset on all Devices and also subsequently disable them. When focus is regained, re-enable all Devices and also issue a sync request on each Device in order to update it to its current state. If a device does not respond to the sync request, soft-reset it. |
Ignore Focus |
Do nothing when focus is lost. When focus is regained, issue a sync request on all Devices. |
Focus behavior has implications for how Actions behave on focus changes. When a Device is reset, Actions bound to Controls on the device will be cancelled. This ensures, for example, that a user-controlled character in your game doesn't continue to move when focus is lost while the user is pressing one of the W, A, S or D keys. The cancellation happens in such a way that Actions are guaranteed to not trigger. That is, even if an Action is set to trigger on button release, it will not get triggered when a button is down and gets reset by a Device reset.