Version: 2021.2
言語: 日本語
コマンドライン引数
Unity スタンドアロンプレイヤーのコマンドライン引数

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

Unity の起動

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

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

Windows では、コマンドプロンプトに以下を入力して Unity を起動します。

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

このように Unity を起動すると、起動時にコマンドと情報を受け取ります。これは、テストスイート、自動ビルド、他のプロダクションタスクに役立ちます。

コンフィギュレーション引数

起動時に付加的なコマンドや情報を加えてエディターを実行し、Unity アプリケーションを構築することができます。このページでは、Unity エディターインスタンスの起動と設定に使用できるコマンドライン引数をまとめています。

オプション 詳細
-createProject <pathname> 特定のパスに空のプロジェクトを作成
-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 overhead when you import assemblies.

This argument is useful if you want to import assemblies that access a Unity API which doesn’t need updating. It’s also useful when you import assemblies which don’t access any Unity APIs (for example, if you have built some or all of your source code 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 needs updating, you might get errors at compile time, run time, or both, that are hard to track.
-disable-gpu-skinning 起動時の GPU (Graphics Processing Unit) スキニングを無効にします。
-executeMethod <ClassName.MethodName> または -executeMethod <NamespaceName.ClassName.MethodName> Unity がプロジェクトを開くと同時に、かつ、アセットサーバーの任意の更新が完了した後に、その静的メソッドを実行します。これは、継続的インテグレーション、ユニットテストの実行、ビルドの作成、データの準備などのタスクに使用できます。

コマンドライン処理のエラーを返すには、リターンコード 1 で Unity を終了させる例外を投げるか、または、0 以外のリターンコードで EditorApplication.Exit を呼び出します。

パラメーターを渡すには、コマンドラインにパラメーターを追加し、System.Environment.GetCommandLineArgs を使って関数内にパラメーターを取得します。-executeMethod を使用するには、含まれているスクリプトを Editor フォルダーに配置する必要があります。 実行するメソッドは static として定義する必要があります。
-exportPackage <exportAssetPath1 exportAssetPath2 ExportAssetPath3 exportFileName> 指定したパス (または複数の指定したパス) にエクスポート。この場合では exportAssetPath は Unity プロジェクトからエクスポートするフォルダー (Unity プロジェクトのルートディレクトリに対する相対パス) であり、exportFileName はパッケージの名前です。このオプションはフォルダー全体の単位でしかエクスポート出来ません。通常このコマンドは -projectPath 引数と一緒に使用する必要があります。
-importPackage <pathname> 指定の アセットパッケージ をインポートします。Unity はインポートダイアログを表示しません。
-job-worker-count <N> Unity JobQueue Job Worker Count の最大スレッド数を指定します。
-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 the - option to direct the output to stdout, which by default is not the console.
-noUpm Unity Package Manager を無効にします。
-openfile <path> シーンファイルやパッケージファイルへのパスからプロジェクトを開くことができます。または、-projectPath 引数を使用することもできます。
-password <password> Unity エディターのアクティベーションのときに、ログインフォームにパスワードを入力します。
-projectPath <pathname> 指定したパスのプロジェクトを開きます。パス名にスペースが含まれている場合は、引用符で囲みます。
-quit コマンドの実行が終了した後に Unity エディターを終了します。これによりエラーメッセージが表示されなくなる場合があります (ただし、エラーメッセージは Editor.log ファイルには保存されます)。
-releaseCodeOptimization リリースコード最適化モードを有効にし、セッションの現在のデフォルトコード最適化モードをオーバーライドします。
-setDefaultPlatformTextureFormat (Android のみ) テクスチャをインポートしたり、プロジェクトをビルドしたりする前に、デフォルトのテクスチャ 圧縮 を希望の形式に設定します。これは、希望の形式で再度テクスチャをインポートする必要がないようにするためです。利用可能なフォーマットは、dxt、pvrtc、atc、etc、etc2、astc です。
-silent-crashes スタンドアロンプレイヤーがクラッシュしたときに表示されるダイアログを Unity が表示しないようにします。この引数は、プレイヤーを自動化されたビルドやテストで実行したい場合に便利です (ダイアログによって自動化された手順が妨げられるのを防ぎます)。
-username <username> Unity エディターのアクティベーションのときに、ログインフォームにユーザー名を入力します。
-vcsMode <mode> バージョン管理モードを設定します。利用可能なモードは、"Visible Meta Files""Hidden Meta Files"Perforce、および PlasticSCM です。指定されたバージョン管理モードの設定フィールドを埋めるために、追加のフラグを使用できます。これらのフラグは、Provider.GetActiveConfigFields メソッドに基づいています。例えば、-vcPerforceUsername-vcPerforcePassword-vcPerforceWorkspace および -vcPerforceServer を使用して Perforce ユーザー名、ワークスペース、サーバーフィールドを設定できます。

ノート: スペースを含む <mode> 引数は、二重引用符 (“) で囲む必要があります。| |-vcsModeSession <mode>|このセッションのバージョン管理モードを設定します。利用可能なモードは、"Visible Meta Files""Hidden Meta Files"Perforce、および PlasticSCM です。指定されたバージョン管理モードの設定フィールドを埋めるために、追加のフラグを使用できます。これらのフラグは、Provider.GetActiveConfigFields メソッドに基づいています。例えば、-vcPerforceUsername-vcPerforcePassword-vcPerforceWorkspace および -vcPerforceServer を使用して Perforce ユーザー名、ワークスペース、サーバーフィールドを設定できます。

ノート: スペースを含む <mode> 引数は、二重引用符 (”) で囲む必要があります。
-version エディターを起動せずに、コマンドラインで Unity エディターのバージョン番号を表示します。

バッチモード引数

Unity のバッチモードを設定するには、以下の引数を使用します。バッチモードは、追加の入力なしに Unity に定義済みのタスクを実行可能にさせるもので、テストなどの自動化されたタスクに便利なモードです。詳細については、バッチモードとビルトインコルーチンの互換性 を参照してください。

オプション 詳細
-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 doesn’t run if you omit this command line argument when you launch Unity in batch mode. This might 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.

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 can’t 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.
-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, because Enlighten requires GPU acceleration.

Build Arguments

Use the following arguments to build players for various platforms from the command line. For more information about building players with command line arguments, see Unity Standalone Player command line arguments.

オプション 詳細
-buildLinux64Player <pathname> 64-bit スタンドアロン Linux player をビルドします (例えば、-buildLinux64Player path/to/your/build)。
-buildOSXUniversalPlayer <pathname> 64-bit スタンドアロン Mac OS X player をビルドします (例えば、-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).

Cache server arguments

Use the following arguments to configure Unity’s use of the cache server. For more information, see Cache Server.

オプション 詳細
-EnableCacheServer より新しい Accelerator Cache Server を使用するように Unity に指示します。また、-cacheServerEndpoint でアドレスを指定する必要があります。
-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> 古い (v1) Cache Server の使用を有効にし、起動時に接続する IP アドレスを指定します。 これにより、エディター設定に保存されている設定がオーバーライドされます。 これを使用すると、Unity の複数のインスタンスを異なる v1 Cache Server に接続できます。

Debugging arguments

オプション 詳細
-disableManagedDebugger デバッガーのリッスンソケットを無効にします。
-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.
-debugCodeOptimization デバッグコード最適化モードを有効にし、セッションの現在のデフォルトコード最適化モードをオーバーライドします。
-enableCodeCoverage EEnables code coverage and allows access to the Coverage API.
-stackTraceLogType Allow detailed debugging. All settings allow None, Script Only and Full to be selected (for example, -stackTraceLogType Full).

Graphics API arguments

Use the following arguments to force the Unity Editor to use a specific graphics API.

オプション 詳細
-force-d3d11(Windows のみ) レンダリングで Direct3D 11 を使用します。通常、グラフィックス API は Player 設定 での値に依存します (デフォルトは D3D11 です)。
-force-d3d12 (Windows のみ) レンダリングで Direct3D 12 を使用します。通常、グラフィックス API は Player 設定 での値に依存します。
-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, the editor uses Direct3D.
-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のみ) レンダリングで端末の OpenGL を使用します。エディターは、ベストな OpenGL ES バージョンと、OpenGL ドライバから利用可能なすべての OpenGL ES 拡張の利用を試みます。
-force-glesXY(Windowsのみ) -force-gles と同じですが、OpenGL ES のコンテキストバージョンをリクエストすることができます。XYに指定できる値は、「30、31、32」です。
-force-vulkan レンダリングで Vulkan を使用します。通常、グラフィックス API は Player 設定 での値に依存します。
-force-clamped -force-glcoreXY と一緒に使用することにより、追加された OpenGL 拡張を Unity が確認することを避けることができます。これにより、同じコードパスで複数のプラットフォーム間で実行できます。

License arguments

Use the following arguments to process a Unity license or run the Unity Editor with different license options.

オプション 詳細
-createManualActivationFile Step one of a three-step process to manually activate a Unity license. For more information, see Generate a license activation file (.alf) from the command line.
-force-free Run the Editor as if there is a free Unity license on the machine, even if a Unity Pro license is installed.
-manualLicenseFile <yourulffile> Step three of a three-step process to manually activate a Unity license. For more information, see Generate a license activation file (.alf) from the command line.
-returnlicense 現在アクティブなライセンスをライセンスサーバーに返却します。詳しくは、ライセンスの返却 を参照してください。
-serial <serial> Activate your Unity license with the specified serial number. For more information, see Activating a license from the command line.

Note: When you use this argument, you must also use the -batchmode argument. It’s also good practice to specify the -quit argument.

Metal arguments (macOS only)

Use the following arguments to configure Unity’s use of the Metal graphics API for Apple devices.

オプション 詳細
-force-device-index Metal を使用する場合に、GPU のインデックスを渡すことによって、エディターに特定の GPU デバイスを使用させます(macOS のみ)。
-force-low-power-device (macOS のみ) Metal を使用する場合に、低消費電力のデバイスを使用させます。
-force-metal デフォルトのグラフィックス API として Metal を使用させます(macOS のみ)。

Profiler arguments

Use the following arguments to configure Unity’s use of the Profiler.

オプション 詳細
-deepprofiling CPU プロファイラー の Deep Profiling (詳細プロファイリング) オプションを有効にします。
-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> この引数は、プロファイルデータを .raw ファイルに送信するように Unity Profiler を設定します。プレイヤーとエディターの両方で使用できます。
-profiler-capture-frame-count <NumberOfFrames> この引数は、起動時に .raw ファイルに送信する場合に、プロファイラーがキャプチャするフレーム数を設定します。プレイヤーでのみ機能します。
-profiler-maxusedmemory デフォルトでは、 Unity Profiler の maxUsedMemory はプレイヤー用に 16MB、エディター用に 256MB です。この引数を使用して、起動時に maxUsedMemory パラメーターをカスタムサイズに設定できます (例えば、-profiler-maxusedmemory 16777216)。サイズはバイト単位で設定します。

*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 -projectPath "C:\Users\UserName\Documents\MyProject" -executeMethod
MyEditorScript.PerformBuild

macOS:

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

Unity Editor special command line arguments

これらの引数は、特殊な環境下または 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.

Extra Editor arguments from packages

これらのパッケージをインストールすると、追加のエディターコマンドライン引数が利用可能になります。

Package 詳細
Burst See Burst package documentation.
Test Framework See Unity Test Framework package documentation.
コマンドライン引数
Unity スタンドアロンプレイヤーのコマンドライン引数
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961