How do you keep your game running even when you switch out of it?

Whenever I run my game in unity or build a standalone, it works fine. When I alt-tab out of it or switch to another program, the program stops going and then continues right where I left off when I come back to it.

I want the game to continue running while I am switched out. Is this possible?

The reason I want to do this is that I'm making a dedicated server and client. I want both programs to continue to run in the background.

Thanks for your help!

In the editor, go to EditProject SettingsPlayer.

The inspector pane will now change to show the player settings.
Look for the option that says "Run In Background" and check it.

This option will be held in both the editor preview and in built games.

In Unity-5-1.4, I’ve found that EditProject SettingsPlayer"Run In Background" checkbox only works when it is checked while Unity Editor is playing, (that it won’t stay checked for future plays in Unity Editor, nor when making a build).

So, I’ve just triggered the setting in an initialization script tied to a root GameObject, and that seems to work fine.

using UnityEngine;
using System.Collections;

public class MyInitializations : MonoBehaviour
{
    public bool debugLog = false;
    public bool runInBackgroundValue = true;

    void Start ()
    {
        Application.runInBackground = true;
    }

    void Update ()
    {
        if (debugLog)
        {
            runInBackgroundValue = Application.runInBackground;
        }

        if (!Application.runInBackground)
        {
            Application.runInBackground = true;

            if (debugLog)
            {
                Debug.Log("Re-Setting Application.runInBackground to TRUE at: " + Time.time);
            }
        }
    }
}

In Unity 2021+, It’s in the “resolution and presentation” block.

Apparently this does not work in Safari (Mac OS) for Unity v2.6.1.

In Unity 5.1.4, I’ve found that Edit → Project Settings → Player → “Run In Background” checkbox only works when it is checked while Unity Editor is playing, (that it won’t stay checked for future plays in Unity Editor, nor when making a build).

So, I’ve just triggered the setting in an initialization script tied to a root GameObject, and that seems to work fine.

^^^^

is that working on android??

If you don’t have that option in the Player Settings, you probably don’t target PC platform. On Android and iOS this flag is ignored, so it’s not there, but it still affects the Editor. Go to PC player settings “Resolution and Presentation”, it will be there.

This option seems to have disappeared in 3.5. Where do we find it now?

This option does not seen to exist in 3.5.6f4 does anyone know how to do this anymore ?