Command line arguments
Unity Manual > Advanced > Command line arguments

Command line arguments

It is possible to start Unity with command line arguments to make it run certain tasks upon opening. This enables automatic execution of Unity through scripts for example.

Possible arguments:

-batchMode

Put Unity into batch mode. This should always be used in conjunction with the other command line arguments as it ensures no pop up windows appear and eliminates the need for any human intervention. When an exception occurs during execution of script code, asset server updates fail or other operations fail Unity will immediately exit with -1.

-quit

Quit Unity cleanly upon finishing execution of other command line arguments.

-compressTextures

This makes sure any imported assets are compressed inside Unity.

-importPackage packagename

Force import the package given. No import dialog is shown.

-createProject pathname

Create an empty project at the given path name.

-projectPath pathname

Open the project at the given path name.

-assetServerUpdate IP[:port] projectname username password

Force an update of the project in the asset server given by IP:port. The port is optional and if not given it is assumed to be the standard one (10733). It is advisable to use this command in conjunction with the -projectPath argument as you ensure you are working with the correct project. In no project name is given then the last project opened by Unity is used. If no project exists at the path given by -projectPath then one is created automatically.

-executeMethod ClassName.MethodName

Execute the given method as soon as Unity is started and the project folder has been opened.

Example usage

Execute Unity in batch mode, execute the test.sss method, and quit upon completion.

C:\program files\Unity\Editor>Unity.exe -quit -batchmode -executeMethod test.sss

Execute Unity in batch mode and enable texture compression. Use the project path given and update from the asset server. Execute the given method after all assets have been downloaded and imported from the asset server. After the method has finished execution, automatically quit Unity.

/Applications/Unity/Unity.app/Contents/MacOS/Unity -batchmode -compressTextures -projectPath ~/Unity\ Projects/AutobuildProject -assetServerUpdate 192.168.1.1 MyGame AutobuildUser l33tpa33 -executeMethod MyClass.ResetEverythingMethod -quit