Version: 2020.3
Unity Editor command line arguments
批处理模式和内置协程兼容性

Unity Standalone Player command line arguments

You can launch Unity Players from the command line and pass in arguments to change how the Player executes.

命令 详细信息:
-batchmode Run the application in “headless” mode. In this mode, the application doesn’t display anything or accept user input. This is useful for running servers for networked applications.
-disable-gpu-skinning Disables Graphics Processing Unit (GPU) skinning at startup.
-force-clamped Use this together with -force-glcoreXY to prevent checks for additional OpenGL extensions, allowing the application to run between platforms with the same code paths.
-force-d3d11-singlethreaded 强制在使用 D3D11_CREATE_DEVICE_SINGLETHREADED 标志的情况下创建 DirectX 11.0。
-force-device-index Make the Standalone Player use a specific GPU device by passing it the index of that GPU. This option is supported for D3D11, D3D12, Metal, and Vulkan graphics APIs, but isn’t supported for OpenGL.
-force-glcore Force the application to use the OpenGL core profile for rendering. The Editor tries to use the most recent OpenGL version available, and all OpenGL extensions exposed by the OpenGL drivers. Unity uses Direct3D if the platform doesn’t support OpenGL.
-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 application to use Vulkan for rendering.
-force-wayland (Linux only) 运行 Linux 播放器时激活实验性 Wayland 支持。
-monitor N 在指定的监视器上运行独立平台播放器,该监视器由基于 1 的索引号指示。
-nographics When you use this argument in batch mode, Unity doesn’t 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. When you don’t use this argument, Unity writes the output_log.txt in the Log Files folder, where the Debug.Log output is printed.
-no-stereo-rendering 关闭立体渲染。
-popupwindow Create the window as a pop-up window, without a frame. This command isn’t supported on macOS.
-screen-fullscreen 覆盖默认的全屏状态。此值必须是 0 或 1。
-screen-height 覆盖默认屏幕高度。此值必须是受支持分辨率中的整数。
-screen-width Override the default screen width. This width value must be an integer from a supported resolution.
-screen-quality 覆盖默认屏幕质量。示例用法为:/path/to/myGame -screen-quality Beautiful。支持的选项与 Quality Settings 名称匹配。
-vrmode <devicetype> Launch with a specific VR device. For more information, see Virtual Reality.
-force-low-power-device(仅限 macOS) 使独立平台播放器使用低功耗设备。
-force-metal(仅限 macOS) 使独立平台播放器使用 Metal 作为默认图形 API。
-force-d3d11(仅限 Windows) Force the application to use Direct3D 11 for rendering.
-force-d3d12(仅限 Windows) Force the application to use Direct3D 12 for rendering.
--parentHWND <HWND> delayed (Windows only) Embed the Windows Standalone application into another application. When you use this argument, 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 runs. 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 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 downloadable example: EmbeddedWindow.zip
-single-instance(仅限 Linux 和 Windows) Run only one instance of the application at the time. If another instance is already running then launching the application again with -single-instance focuses the existing one.
-window-mode(仅限 Windows) Override fullscreen windowed mode. Accepted values are exclusive or borderless. For more information, see Standalone Player settings.

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");

应在 appCallbacks.Initialize() 函数之前调用此函数。

命令 详细信息:
-force-d3d11-singlethreaded 强制在使用 D3D11_CREATE_DEVICE_SINGLETHREADED 标志的情况下创建 DirectX 11.0。
-force-driver-type-warp Force the DirectX 11.0 driver type WARP device. For more information, see Microsoft’s documentation on Windows Advanced Rasterization Platform.
-force-feature-level-9-3 强制使用 DirectX 11.0 功能级别 9.3。
-force-feature-level-10-0 强制使用 DirectX 11.0 功能级别 10.0。
-force-feature-level-10-1 强制使用 DirectX 11.0 功能级别 10.1。
-force-feature-level-11-0 强制使用 DirectX 11.0 功能级别 11.0。
-force-gfx-direct 强制使用单线程渲染。
-nolog Don’t produce UnityPlayer.log.
Unity Editor command line arguments
批处理模式和内置协程兼容性