ビルドプレイヤーパイプライン
バッチモードとビルトインコルーチンの互換性

コマンドライン引数

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

Launching Unity

macOS で Unity を起動するには、以下をターミナルに入力します。

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

Windows で 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 games.

サイレントモードで Unity を起動

macOS で 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.

Windows で Unity をサイレントモードで起動するには、コマンドプロンプトに以下を入力します。

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

ライセンスをライセンスサーバーに返却

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

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

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.

オプション

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

オプション 説明
-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. Always use this in conjunction with the other command line arguments to ensure no pop-up windows appear and eliminate the need for any human intervention. 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> 64-bit スタンドアロン Linux player をビルドします (例えば、-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> 32bit スタンドアロン Windows プレイヤーをビルドします (例えば、-buildWindowsPlayer path/to/your/build.exe )。
-buildWindows64Player <pathname> 64bit スタンドアロン Windows player をビルドします (例えば、-buildWindows64Player path/to/your/build.exe )。
-CacheServerIPAddress <host:port> Connect to the Cache Server you specify on startup, overriding any configuration stored in the Editor Preferences. Use this to connect multiple instances of Unity to different Cache Servers.
-createProject <pathname> 特定のパスに空のプロジェクトを作成
-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.
-diag-debug-shader-compiler Unity launches only one instance of the Shader Compiler, and forces its timeout to be one hour. Useful for debugging Shader Compiler issues.
-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 continous 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> 指定したパス (または複数の指定したパス) にエクスポート。この場合では exportAssetPath は Unity プロジェクトからエクスポートするフォルダー (Unity プロジェクトのルートディレクトリに対する相対パス) であり、exportFileName はパッケージの名前です。現在、このオプションはフォルダー全体の単位でしかエクスポート出来ません。通常このコマンドは -projectPath 引数と一緒に使用する必要があります。
-force-d3d11(Windowsのみ) Make the Editor use Direct3D 11 for rendering. Normally the graphics API depends on Player Settings (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 Metal を使用する場合に、GPU のインデックスを渡すことによって、エディターに特定の GPU デバイスを使用させます(macOS のみ)。
-force-gfx-metal デフォルトのグラフィックス API として Metal を使用させます(macOS のみ)。
-force-glcore レンダリングに OpenGL 3/4 コアプロファイルを使用します。エディターは、利用可能でベストな OpenGL バージョンと、OpenGL ドライバがアクセスできるすべての OpenGL 拡張の利用を試みます。そのプラットフォームがサポートされていない場合は、Direct3D を使用します。
-force-glcoreXY -force-glcore と同じですが、OpenGL のバージョンを指定することができます。XYに指定できる値は、「32、33、40、41、42、43、44、54」です。
-force-gles(Windowsのみ) レンダリングで端末の OpenGL を使用します。エディターは、ベストな OpenGL ES バージョンと、OpenGL ドライバから利用可能なすべての OpenGL ES 拡張の利用を試みます。
-force-glesXY(Windowsのみ) -force-gles と同じですが、OpenGL ES のコンテキストバージョンをリクエストすることができます。XYに指定できる値は、「30、31、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 Unity Pro ライセンスがインストールされていても、マシン上に無料 Unity ライセンスがあるかのようにエディターを動作させます。
-force-low-power-device (macOS only) If you use Metal, make the Editor use a low power device.
-importPackage <pathname> 特定の パッケージ をインポートします。インポートダイアログは表示されません。
-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 Enlighten requires GPU acceleration.
-noUpm 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.
-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).
-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. ou 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 compression 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, pvrtc, atc, etc, etc2, and astc.
-silent-crashes スタンドアロンプレーヤーがクラッシュしたときに表示されるダイアログを Unity が表示しないようにします。 この引数は、プレイヤーを自動化されたビルドやテストで実行したい場合に便利です (ダイアログによって自動化された手順が妨げられるのを防ぎます)。
-stackTraceLogType Allow detailed debugging. All settings allow None, Script Only and Full to be selected. (for example, -stackTraceLogType Full)
-testPlatform, -testResults, -runTests Run tests. See Unity Test Runner documentation.
-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 mode are Visible Meta Files, Hidden Meta Files, Perforce and PlasticSCM

C# script in the project:

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

以下のコマンドは Unity をバッチモードで実行し、MyEditorScript.PerformBuild メソッドを実行し、その後、完了時に終了します。

Windows:

"C:\Program Files\Unity\Editor\Unity.exe" -quit -batchmode -executeMethod MyEditorScript.PerformBuild

Mac OS:

/Applications/Unity/Unity.app/Contents/MacOS/Unity -quit -batchmode -executeMethod MyEditorScript.PerformBuild

Unity エディターの特別なコマンドライン引数

これらの引数は、特殊な環境下または Unity サポートから指示されたときのみ使用してください。

オプション 説明
-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.

Unity スタンドアロンプレイヤーのコマンドライン引数

Unityでビルドしたスタンドアロンプレイヤーはコマンドライン引数を読み取ることができます。

オプション 説明
-monitor N Run Standalone Player on the specified monitor, indicated by a 1-based index number.
-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.
-force-d3d11(Windowsのみ) 強制的にレンダリングでDirect3D 11を使用します。
-force-d3d11-singlethreaded D3D11_CREATE_DEVICE_SINGLETHREADEDフラグで、DirectX 11.0 を強制的に作成します。
-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 Vulcan graphics APIs, but is not supported for OpenGL.
-force-gfx-metal (macOS only) Make the Standalone Player use Metal as the default graphics API.
-force-glcore Force the game to use OpenGL 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 -force-glcore と同じですが、OpenGL のバージョンを指定することができます。XYに指定できる値は、「32、33、40、41、42、43、44、54」です。
-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 Linux プレイヤーを実行するときに、実験的な Wayland サポートをアクティベートします。
-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.
-parentHWND <HWND> delayed(Windowsのみ) 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 デフォルトのフルスクリーン状態をオーバーライドします。値は 0 か 1 のいずれかです。
-screen-height デフォルトの画面の高さをオーバーライドします。サポートされている解像度の整数である必要があります。
-screen-width デフォルトの画面の幅をオーバーライドします。サポートされている解像度の整数である必要があります。
-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.
-show-screen-selector 強制的に画面選択のダイアログボックスを表示させます。
-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 Reality for details.
-window-mode (Windows only) Override fullscreen windowing mode. Accepted values are exclusive or borderless. See Standalone Player settings for details.

ユニバーサル Windows プラットフォーム コマンドライン引数

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() 関数の前に呼び出します。

オプション 説明
-nolog UnityPlayer.log を生成しません。
-force-driver-type-warp DirectX 11.0 WARP を強制します (詳細については Microsoft の文書 Windows Advanced Rasterization Platform を参照してください)。
-force-d3d11-singlethreaded D3D11_CREATE_DEVICE_SINGLETHREADEDフラグで、DirectX 11.0 を強制的に作成します。
-force-gfx-direct シングルスレッドレンダリングを強制します。
-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 を強制します。

  • 2019–04–18 Page amended

  • “accept-apiupdate” コマンドラインオプションは Unity 2017.2 で追加NewIn20172

  • “accept-apiupdate” コマンドライン引数は Unity 2017.3 で追加NewIn20172

  • Tizen サポートは2017.3 で打ち切りNewIn20173

  • “noUpm”、 “setDefaultPlatformTextureFormat”、 “CacheServerIPAddress” コマンドラインオプションは Unity 2018.1 で追加 NewIn20181

  • “Application.isBatchMode” 演算子は2018.2 で追加 NewIn20182

ビルドプレイヤーパイプライン
バッチモードとビルトインコルーチンの互換性