Detect Batch Mode

Is there a way to know, in a C# script, that Unity is being run in batchmode?

Since you launch Unity into batch mode by passing a command line argument (“-batchmode”), you can just check command line arguments for existence of it. System.Environment.GetCommandLineArgs for example.


true or false, simple as that.

Oh and there is also:


all power to the machines! :slight_smile:

We recently added an option that lets you query this directly:


The documentation can be found here:

string commandLineOptions = System.Environment.CommandLine;

   if (commandLineOptions.Contains("-batchmode") )
       Debug.Log("Batch mode!");
   else if (commandLineOptions.Contains("-nographics") )
      Debug.Log("No Graphcis Mode");

In batchmode there shouldn’t be any graphics device so go with this:

if(SystemInfo.graphicsDeviceID == 0)