Version: 2020.1
Multi-Scene editing
Batch mode and built-in coroutine compatibility

Command line arguments

You can run Unity from the command line (from the macOS Terminal or the Windows Command Prompt).

Launching Unity

On macOS, type the following into the Terminal to launch Unity:

/Applications/Unity/Unity.app/Contents/MacOS/Unity

On Windows, type the following into the Command Prompt to launch Unity:

"C:\Program Files\Unity\Editor\Unity.exe"

When you launch Unity like this, it receives commands and information on startup, which can be very useful for test suites, automated builds and other production tasks. Note: Use the same method to launch standalone Unity applications.

Launching Unity silently

On macOS, type the following into the Terminal to silently launch Unity:

/Applications/Unity/Unity.app/Contents/MacOS/Unity -quit -batchmode -serial SB-XXXX-XXXX-XXXX-XXXX-XXXX -username 'JoeBloggs@example.com' -password 'MyPassw0rd'

Note: If you use continuous integration (CI) tools like Jenkins to activate via the command line, add the -nographics flag to prevent a WindowServer error.

On Windows, type the following into the Command Prompt to silently launch Unity:

"C:\Program Files\Unity\Editor\Unity.exe" -batchmode -username name@example.edu.uk -password XXXXXXXXXXXXX -serial E3-XXXX-XXXX-XXXX-XXXX-XXXX –quit

Returning the license to the license server

On macOS, type the following into the Terminal to return the license:

/Applications/Unity/Unity.app/Contents/MacOS/Unity -quit -batchmode -returnlicense

On Windows:

"C:\Program Files\Unity\Editor\Unity.exe" -quit -batchmode -returnlicense

Returning the license is useful when you no longer want to use Unity on the machine, and want to use the same license on another machine.

Create a license activation file and import license file by command

On macOS, type the following into the Terminal:

/Applications/Unity/Unity.app/Contents/MacOS/Unity -batchmode -createManualActivationFile -logfile

/Applications/Unity/Unity.app/Contents/MacOS/Unity -batchmode -manualLicenseFile <yourulffile> -logfile

On Windows, type the following into the Command Prompt:

"C:\Program Files\Unity\Editor\Unity.exe" -batchmode -createManualActivationFile -logfile

"C:\Program Files\Unity\Editor\Unity.exe" -batchmode -manualLicenseFile <yourulffile> -logfile

For more details, read the Manual Activation Guide.

Options

You can run the Editor and build Unity applications with additional commands and information on startup. This section describes the command line options available.

Command Details
-accept-apiupdate Use this command line option to specify that APIUpdater should run when Unity is launched in batch mode.

Example:

unity.exe -accept-apiupdate -batchmode [other params]

The APIUpdater will not run if you omit this command line argument when you launch Unity in batch mode. This can lead to compiler errors.
-batchmode Run Unity in batch mode. In batch mode, Unity runs command line arguments without the need for human interaction. It also suppresses pop-up windows that require human interaction (such as the Save Scene window); however, the Unity Editor itself opens as usual. You should always run Unity in batch mode when using command line arguments, because it allows automation to run without interruption.

When an exception occurs during execution of the script code, the Asset server updates fail, or other operations fail, Unity immediately exits with return code 1.

Note that in batch mode, Unity sends a minimal version of its log output to the console. However, the Log Files still contain the full log information. You cannot open a project in batch mode while the Editor has the same project open; only a single instance of Unity can run at a time.

To check whether the Editor or Standalone Player is running in batch mode, use the Application.isBatchMode operator.

If the project has not yet been imported when using -batchmode, the target platform is the default one. To force a different platform, use the -buildTarget option.
-buildLinux64Player <pathname> Build a 64-bit standalone Linux player (for example, -buildLinux64Player path/to/your/build).
-buildOSXUniversalPlayer <pathname> Build a 64-bit standalone Mac OSX player (for example, -buildOSXUniversalPlayer path/to/your/build.app).
-buildTarget <name> Select an active build target before loading a project. Possible options are:
Standalone, Win, Win64, OSXUniversal, Linux64, iOS, Android, WebGL, XboxOne, PS4, WindowsStoreApps, Switch, tvOS.
-buildWindowsPlayer <pathname> Build a 32-bit standalone Windows player (for example, -buildWindowsPlayer path/to/your/build.exe).
-buildWindows64Player <pathname> Build a 64-bit standalone Windows player (for example, -buildWindows64Player path/to/your/build.exe).
-createProject <pathname> Create an empty project at the given path.
-debugCodeOptimization Enables debug code optimization mode, overriding the current default code optimization mode for the session.
-deepprofiling Enable Deep Profiling option for the CPU profiler.
-disable-assembly-updater <assembly1 assembly2> Specify a space-separated list of assembly names as parameters for Unity to ignore on automatic updates.
The space-separated list of assembly names is optional: pass the command line options without any assembly names to ignore all assemblies, as in example 1.

Example 1
unity.exe -disable-assembly-updater

Example 2
unity.exe -disable-assembly-updater A1.dll subfolder/A2.dll

Example 2 has two assembly names, one with a pathname. Example 2 ignores A1.dll, no matter what folder it is stored in, and ignores A2.dll only if it is stored under subfolder folder:

If you list an assembly in the -disable-assembly-updater command line parameter (or if you don’t specify assemblies), Unity logs the following message to Editor.log:

[Assembly Updater] warning: Ignoring assembly [assembly_path] as requested by command line parameter.”).

Use this to avoid unnecessary API Updater overheads when importing assemblies.

It is useful for importing assemblies which access a Unity API when you know the Unity API doesn’t need updating. It is also useful when importing assemblies which do not access Unity APIs at all (for example, if you have built your source code, or some of it, outside of Unity, and you want to import the resulting assemblies into your Unity project).

Note: If you disable the update of any assembly that does need updating, you may get errors at compile time, run time, or both, that are hard to track.
-disableManagedDebugger Disables the debugger listen socket.
-diag-debug-shader-compiler Unity launches only one instance of the ShaderA small script that contains the mathematical calculations and algorithms for calculating the Color of each pixel rendered, based on the lighting input and the Material configuration. More info
See in Glossary
Compiler, and forces its timeout to be one hour. Useful for debugging Shader Compiler issues.
-disable-gpu-skinning Disable GPU skinningThe process of binding bone joints to the vertices of a character’s mesh or ‘skin’. Performed with an external tool, such as Blender or Autodesk Maya. More info
See in Glossary
at startup.
-enableCodeCoverage Enables code coverage and allows access to the Coverage API.
-executeMethod <ClassName.MethodName> or -executeMethod <NamespaceName.ClassName.MethodName> Execute the static method as soon as Unity opens the project, and after the optional Asset server update is complete. You can use this to do tasks such as continuous integration, performing Unit Tests, making builds or preparing data. To return an error from the command line process, either throw an exception which causes Unity to exit with return code 1, or call EditorApplication.Exit with a non-zero return code. To pass parameters, add them to the command line and retrieve them inside the function using System.Environment.GetCommandLineArgs. To use -executeMethod, you need to place the enclosing script in an Editor folder. The method you execute must be defined as static.
-exportPackage <exportAssetPath1 exportAssetPath2 ExportAssetPath3 exportFileName> Export a package, given a path (or set of given paths). In this example exportAssetPath is a folder (relative to to the Unity project root) to export from the Unity project, and exportFileName is the package name. Currently, this option only exports whole folders at a time. You normally need to use this command with the -projectPath argument.
-force-d3d11 (Windows only) Make the Editor use Direct3D 11 for renderingThe process of drawing graphics to the screen (or to a render texture). By default, the main camera in Unity renders its view to the screen. More info
See in Glossary
. Normally the graphics API depends on Player SettingsSettings that let you set various player-specific options for the final game built by Unity. More info
See in Glossary
(typically defaults to D3D11).
-force-d3d12 (Windows only) Make the Editor use Direct3D 12 for rendering. Normally the graphics API depends on Player Settings.
-force-device-index When using Metal, make the Editor use a particular GPU device by passing it the index of that GPU (macOS only).
-force-metal Make the Editor use Metal as the default graphics API (macOS only).
-force-glcore Make the Editor use OpenGL 3/4 core profile for rendering. The Editor tries to use the best OpenGL version available and all OpenGL extensions exposed by the OpenGL drivers. If the platform isn’t supported, Direct3D is used.
-force-glcoreXY Similar to -force-glcore, but requests a specific OpenGL context version. Accepted values for XY: 32, 33, 40, 41, 42, 43, 44 or 45.
-force-gles (Windows only) Make the Editor use OpenGL for Embedded Systems for rendering. The Editor tries to use the best OpenGL ES version available, and all OpenGL ES extensions exposed by the OpenGL drivers.
-force-glesXY (Windows only) Similar to -force-gles, but requests a specific OpenGL ES context version. Accepted values for XY: 30, 31 or 32.
-force-vulkan Make the Editor use Vulkan for rendering. Normally the graphics API depends on Player Settings.
-force-clamped Use this with -force-glcoreXY to prevent Unity from checking for additional OpenGL extensions, allowing it to run between platforms with the same code paths.
-force-free Make the Editor run as if there is a free Unity license on the machine, even if a Unity Pro license is installed.
-force-low-power-device (macOS only) If you use Metal, make the Editor use a low power device.
-importPackage <pathname> Import the given packageA container that stores various types of features and assets for Unity, including Editor or Runtime tools and libraries, Asset collections, and project templates. Packages are self-contained units that the Unity Package Manager can share across Unity projects. Most of the time these are called packages, but occasionally they are called Unity Package Manager (UPM) packages. More info
See in Glossary
. No import dialog is shown.
-job-worker-count <N> Specify the maximum thread count for the Unity JobQueue Job Worker Count. You can also specify it as job-worker-count=<N> in boot.config for the Unity Standalone Player.
-logFile <pathname> Specify where Unity writes the Editor or Windows/Linux/OSX standalone log file. To output to the console, specify - for the path name. On Windows, specify - option to make the output go to stdout, which is not the console by default.
-nographics When you run this in batch mode, it does not initialize the graphics device. You can then run automated workflows on machines that don’t have a GPU. Automated workflows only work when you have a window in focus, otherwise you can’t send simulated input commands. -nographics does not allow you to bake GI as EnlightenA lighting system by Geomerics used in Unity for lightmapping and for Realtime Global Illumination. More info
See in Glossary
requires GPU acceleration.
-noUpm Disables the Unity Package Manager.
-openfile <path> Open the project from a path to a scene or package file. Alternative is to use -projectPath argument.
-password <password> Enter a password into the log-in form during the activation of the Unity Editor.
-profiler-enable Profile the start-up of a Player or the Editor. When you use this argument with a Player, it has the same effect as building the Player with the Autoconnect Profiler option enabled in Build Settings.

When you use this argument with the Editor, it starts collecting and displaying Profiler information in the Profiler window on start-up of the Editor.
-profiler-log-file <Path/To/Log/File.raw> This argument sets up the Unity Profiler to stream the profile data to a .raw file on startup. It works for both Players and the Editor.
-profiler-capture-frame-count <NumberOfFrames> This argument sets how many frames the Profiler should capture in a profile when streaming to a .raw file on start-up. It only works on Players.
-profiler-maxusedmemory By default, maxUsedMemory for the Unity ProfilerA window that helps you to optimize your game. It shows how much time is spent in the various areas of your game. For example, it can report the percentage of time spent rendering, animating or in your game logic. More info
See in Glossary
is 16MB for Players and 256MB for the Editor. You can use this argument to set the maxUsedMemory parameter to a custom size at start-up (for example, -profiler-maxusedmemory 16777216). The size is set in bytes.
-projectPath <pathname> Open the project at the given path. If pathname contains spaces, enclose it in quotes.
-quit Quit the Unity Editor after other commands have finished executing. This can cause error messages to be hidden (however, they still appear in the Editor.log file).
-releaseCodeOptimization Enables release code optimization mode, overriding the current default code optimization mode for the session.
-returnlicense Return the currently active license to the license server. You should wait a few seconds before Unity removes the license file, because it needs to communicate with the license server.
-serial <serial> Activate Unity with the specified serial key. When you use this to automatically activate Unity, you must pass the -batchmode, and it is good practice to pass the -quit argument. You should wait a few seconds before Unity removes the license file, because it needs to communicate with the license server. Make sure that license file folder exists, and it has appropriate permissions before you run Unity with this argument. If activation fails, see the Editor.log for info.
-setDefaultPlatformTextureFormat (Android only) Set the default texture compression3D Graphics hardware requires Textures to be compressed in specialised formats which are optimized for fast Texture sampling. More info
See in Glossary
to the desired format before you import a texture or build the project. This is so you don’t have to import the texture again with the format you want. The available formats are dxt, pvrtcPowerVR Texture Compression (PVRTC) is a fixed-rate texture format that compresses textures to significantly reduce file sizes without causing a noticable reduction in image quality. More info
See in Glossary
, atcAMD’s texture compression format for handheld devices to save on power, memory and bandwidth
See in Glossary
, etc, etc2, and astcAdaptive Scalable Texture Compression (ASTC) A block-based texture format that compresses textures to significantly reduce file sizes without cau sing a noticable reduction in image quality. More info
See in Glossary
.
-silent-crashes Prevent Unity from displaying the dialog that appears when a Standalone Player crashes. This argument is useful when you want to run the Player in automated builds or tests, where you don’t want a dialog prompt to obstruct automation.
-stackTraceLogType Allow detailed debugging. All settings allow None, Script Only and Full to be selected. (for example, -stackTraceLogType Full)
-username <username> Enter a username into the log-in form during the activation of the Unity Editor.
-vcsMode <mode> Set version control mode for this session. Available modes are "Visible Meta Files", "Hidden Meta Files", Perforce, and PlasticSCM. Additional flags can be used to fill out the configuration fields for the given version control mode. These flags are based on the Provider.GetActiveConfigFields method. For example, you can use the -vcPerforceUsername, -vcPerforcePassword, -vcPerforceWorkspace and -vcPerforceServer to set the Perforce username, workspace and server fields.

Note: <mode> arguments that contain spaces must be wrapped in double quotes (").
-EnableCacheServer Tells Unity to enable usage of the newer Accelerator Cache Server. You must also use -cacheServerEndpoint to specify the address.
-cacheServerEndpoint Specifies the endpoint address if you are using the newer Accelerator Cache Server.

Example:

-cacheServerEndpoint 127.0.0.1:10080. This overrides any configuration stored in the Editor Preferences. Use this to connect multiple instances of Unity to different Cache Servers.
-cacheServerNamespacePrefix Set the namespace prefix for the newer Accelerator Cache Server. Used to group data together on the Cache Server.

Example:

-cacheServerNamespacePrefix MyProject
-cacheServerEnableDownload Enable downloading from the newer Accelerator Cache Server.

Example:

-cacheServerEnableDownload true
-cacheServerEnableUpload Enable uploading to the newer Accelerator Cache Server.

Example:

-cacheServerEnableUpload false
-CacheServerIPAddress <host:port> Enables usage of the older (v1) Cache Server, and specifies the IP Address to connect to on startup. This overrides any configuration stored in the Editor Preferences. Use this to connect multiple instances of Unity to different v1 Cache Servers.

Examples

C# script in the project:

using UnityEditor;
class MyEditorScript
{
     static void PerformBuild ()
     {
         string[] scenes = { "Assets/MyScene.unity" };
         BuildPipeline.BuildPlayer(scenes, ...);
     }
}

The following command executes Unity in batch mode, executes the MyEditorScript.PerformBuild method, and then quits upon completion.

Windows:

"C:\Program Files\Unity\Editor\Unity.exe" -quit -batchmode -projectPath "C:\Users\UserName\Documents\MyProject" -executeMethod MyEditorScript.PerformBuild

Mac OS:

/Applications/Unity/Unity.app/Contents/MacOS/Unity -quit -batchmode -projectPath ~/UnityProjects/MyProject -executeMethod MyEditorScript.PerformBuild

Unity Editor special command line arguments

You should only use these under special circumstances, or when directed by Unity Support.

Command Details
-enableIncompatibleAssetDowngrade Use this when you have Assets made by a newer, incompatible version of Unity, that you want to downgrade to work with your current version of Unity. When you enable this, Unity presents you with a dialog asking for confirmation of this downgrade if you attempt to open a project that would require it.
Note: This procedure is unsupported and highly risky, and should only be used as a last resort.

Extra Editor arguments from packages

Additional Editor command line arguments are available when these packages are installed.

Package Details
Burst See Burst package documentation.
Test Framework See Unity Test Framework package documentation.

Unity Standalone Player command line arguments

Standalone players built with Unity also understand some command line arguments:

Command Details
-batchmode Run the game in “headless” mode. The game does not display anything or accept user input. This is useful for running servers for networked games.
-disable-gpu-skinning Disable GPU skinning at startup.
-force-d3d11 (Windows only) Force the game to use Direct3D 11 for rendering.
-force-d3d11-singlethreaded Force DirectX 11.0 to be created with a D3D11_CREATE_DEVICE_SINGLETHREADED flag.
-force-d3d12 (Windows only) Force the game to use Direct3D 12 for rendering.
-force-device-index Make the Standalone Player use a particular GPU device by passing it the index of that GPU. This option is supported for D3D11, D3D12, Metal, and Vulkan graphics APIs, but is not supported for OpenGL.
-force-metal (macOS only) Make the Standalone Player use Metal as the default graphics API.
-force-glcore Force the game to use OpenGL coreThe back-end Unity uses to support the latest OpenGL features on Windows, MacOS X and Linux. More info
See in Glossary
profile for rendering. The Editor tries to use the best OpenGL version available, and all OpenGL extensions exposed by the OpenGL drivers. If the platform isn’t supported, Direct3D is used.
-force-glcoreXY Similar to -force-glcore, but requests a specific OpenGL context version. Accepted values for XY: 32, 33, 40, 41, 42, 43, 44 or 45.
-force-vulkan Force the game to use Vulkan for rendering.
-force-clamped Use this together with -force-glcoreXY to prevent checking for additional OpenGL extensions, allowing it to run between platforms with the same code paths.
-force-low-power-device (macOS only) Make the Standalone Player use a low power device.
-force-wayland Activate experimental Wayland support when running a Linux player.
-monitor N Run Standalone Player on the specified monitor, indicated by a 1-based index number.
-nographics When you run this in batch mode, it does not initialize a graphics device. This makes it possible to run your automated workflows on machines that don’t have a GPU.
-nolog Do not produce an output log. Normally Unity writes the output_log.txt in the Log Files folder, where the Debug.Log output is printed.
-no-stereo-rendering Turn off stereo rendering.
-parentHWND <HWND> delayed (Windows only) Embed the Windows Standalone application into another application. When you use this, you need to pass the parent application’s window handle (‘HWND’) to the Windows Standalone application.

When you pass -parentHWND 'HWND' delayed, the Unity application is hidden while it is running. You must also call SetParent from the Microsoft Developer library for Unity in the application. Microsoft’s SetParent embeds the Unity window. When it creates Unity processes, the Unity window respects the position and size provided as part of the Microsoft’s STARTUPINFO structure.

To resize the Unity window, check its GWLP_USERDATA in Microsoft’s GetWindowLongPtr function. Its lowest bit is set to 1 when the graphics initialize and it’s safe to resize. Its second lowest bit is set to 1 after the Unity splash screen finishes displaying.
For more information, see this example: EmbeddedWindow.zip
-popupwindow Create the window as a a pop-up window, without a frame. This command is not supported on macOS.
-screen-fullscreen Override the default full-screen state. This must be 0 or 1.
-screen-height Override the default screen height. This must be an integer from a supported resolution.
-screen-width Override the default screen width. This must be an integer from a supported resolution.
-screen-quality Override the default screen quality. Example usage would be: /path/to/myGame -screen-quality Beautiful. The supported options match the Quality Settings names.
-single-instance (Linux and Windows only) Run only one instance of the application at the time. If another instance is already running then launching it again with -single-instance focuses the existing one.
-vrmode <devicetype> Launch with a specific VR device. See Virtual RealityA system that immerses users in an artificial 3D world of realistic images and sounds, using a headset and motion tracking. More info
See in Glossary
for details.
-window-mode (Windows only) Override fullscreen windowing mode. Accepted values are exclusive or borderless. See Standalone Player settings for details.

Universal Windows Platform command line arguments

Universal Windows Apps don’t accept command line arguments by default, so to pass them you need to call a special function from MainPage.xaml.cs/cpp or MainPage.cs/cpp. For example:

appCallbacks.AddCommandLineArg("-nolog");

You should call this before the appCallbacks.Initialize() function.

Command Details
-nolog Don’t produce UnityPlayer.log.
-force-driver-type-warp Force the DirectX 11.0 driver type WARP device (see Microsoft’s documentation on Windows Advanced Rasterization Platform for more information).
-force-d3d11-singlethreaded Force DirectX 11.0 to be created with a D3D11_CREATE_DEVICE_SINGLETHREADED flag.
-force-gfx-direct Force single threaded rendering.
-force-feature-level-9-3 Force DirectX 11.0 feature level 9.3.
-force-feature-level-10-0 Force DirectX 11.0 feature level 10.0.
-force-feature-level-10-1 Force DirectX 11.0 feature level 10.1.
-force-feature-level-11-0 Force DirectX 11.0 feature level 11.0.

  • “accept-apiupdate” command line option added in Unity 2017.2 NewIn20172

  • “-force-clamped” command line argument added in Unity 2017.3 NewIn20172

  • Tizen support discontinued in 2017.3 NewIn20173

  • “noUpm”, “setDefaultPlatformTextureFormat” and “CacheServerIPAddress” command line options added in Unity 2018.1 NewIn20181

  • “Application.isBatchMode” operator added in 2018.2 NewIn20182

Multi-Scene editing
Batch mode and built-in coroutine compatibility
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961