docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Enum InputSettings.BackgroundBehavior

    Determines how the applications behaves when running in the background. See backgroundBehavior.

    Namespace: UnityEngine.InputSystem
    Assembly: Unity.InputSystem.dll
    Syntax
    public enum InputSettings.BackgroundBehavior
    Remarks

    Limitations:

    Receiving input while the application is not in the foreground is platform and device-dependent, and should not be relied upon. IgnoreFocus does not grant the ability to receive input in the background; it only prevents the Input System from resetting/disabling devices on focus changes.

    Specifically:

    Keyboard: InputSystem doesn't receive events while unfocused. Even on platforms where OS-level hooks could technically capture background keyboard input, Unity doesn't forward it to the managed Input System.

    Mouse: Only receives events when the cursor is hovering over the application window.

    XR HMDs: May continue receiving tracking data while unfocused, depending on the XR runtime. These devices report canRunInBackground == true and are the primary use case for ResetAndDisableNonBackgroundDevices, which leaves them untouched while resetting everything else.

    Fields

    Name Description
    IgnoreFocus

    Ignore all changes in focus and leave devices untouched. This also disables focus checks in InputSystemUIInputModule. This mode doesn't disable devices when the application loses focus. It also doesn't reset or sync device state on focus changes. As a result, input controls may retain a stale state after focus transitions. For example, if a key is held when the application loses focus and released while unfocused, the Input System still reports that key as pressed when the focus returns. This is the expected behavior, not a bug. If you need a reliable state after focus changes, use ResetAndDisableNonBackgroundDevices (default) or ResetAndDisableAllDevices.

    ResetAndDisableAllDevices

    Like ResetAndDisableNonBackgroundDevices but instead treat all devices as having canRunInBackground return false. This effectively means that all input is silenced while the application is running in the background.

    ResetAndDisableNonBackgroundDevices

    When the application loses focus, issue a ResetDevice(InputDevice, bool) call on every InputDevice that is not marked as canRunInBackground and then disable the device (see DisableDevice(InputDevice, bool) and enabled). Devices that canRunInBackground will not be touched and will keep running as is.

    In effect, this setting will "soft-reset" all devices that cannot receive input while the application does not have focus. That is, it will reset all controls that are not marked as dontReset to their default state.

    When the application comes back into focus, all devices that have been reset and disabled will be re-enabled and a synchronization request (see RequestSyncCommand) will be sent to each device.

    Devices that are added while the application is running in the background are treated like devices that were already present when losing focus. That is, if they cannot run in the background, they will be disabled until focus comes back.

    Note that the resets will cancel InputActions that are in progress from controls on devices that are being reset.

    See Also
    https://docs.unity3d.com/ScriptReference/Application-isFocused.html
    https://docs.unity3d.com/ScriptReference/Application-runInBackground.html
    backgroundBehavior
    editorInputBehaviorInPlayMode
    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)