You can usually start a program by double-clicking the Unity icon on the desktop, but you can also run the program from the command line (for example, MacOS Terminal or Windows Command Window). If you start Unity this way, it will be able to accept startup commands and information, which will be very helpful for test suites, automated builds, and other authoring tasks.
In MacOS, you can start unity:-by entering the following in the terminal (Terminal)
/Applications/Unity/Unity.app/Contents/MacOS/Unity
... In Windows, you should enter in the CMD window:
"C:\Program Files (x86)\Unity\Editor\Unity.exe"
Standalone Unity games can be launched in the same way.
Command-line arguments
As mentioned above, other commands and information can also be used selectively when launching the editor and building the game. Use the following command-line arguments to achieve this:-
-
-
-batchmode
-
-
run Unity in batch mode. This command line should always be used in conjunction with other command-line arguments because it ensures that no pop-up is done without any human intervention. When an exception occurs while executing script code, a resource server update fails, or another operation fails, Unity exits immediately and returns code 1. Note: In batch mode, Unity sends the minimum version of the log output to the console. Of course, the resource bundle. The Import dialog box is not displayed.
-
-
-createproject <pathname>
-
-
creates an empty project on the specified path.
-
-
-projectpath <pathname>
-
-
opens the project at the specified path.
-
-
-logfile <pathname>
-
-
Specifies the location of the write editor or Windows standalone log file.
-
-
-assetserverupdate <ip[:p ort] projectName username password [r <revision>]>
-
A
-
project update is enforced in the resource server (Asset server) that is given in the
ip:port section. The port is optional and if not specified, it is assumed to be a standard port (10733). It is recommended that this command be used in conjunction with the
-projectpath parameter to ensure that the correct project is updated. If the project name is not given, the last project that Unity opened is used. If the path specified by
-projectpath does not exist for the project, the project will be created automatically.
-
-
-exportpackage <exportassetpath1 exportAssetPath2 ExportAssetPath3 exportfilename>
-
-
exports a resource bundle based on the given path (or set of paths given). Exportassetpath is a folder that is exported from a unity project (relative to the root of the Unity Project), and Exportfilename refers to the name of the resource bundle. Currently, this option can only export the entire folder. This parameter usually needs to be used in conjunction with the-projectpath parameter.
-
-
-nographics (Windows only)
-
When
-
running in batch mode, it is not necessary to initialize the graphics device at all. This allows you to run the workflow automatically on the machine, even without the GPU (the automatic workflow can only be run if the focus is on the window, or the analog input command will not be sent). The standalone player generated with this option does not have any graphics.
-
-
-executemethod <ClassName.MethodName>
-
-
Static class functions are executed immediately after Unity is started, after the project is opened, and after an optional resource server update is performed. This parameter can be used to continuously consolidate, perform unit tests, complete builds, prepare data, and more. If you want to return an error from the command line (commandline), you can throw an exception, causing Unity to exit with a value of 1, or call Editorapplication.exit with a non-0 code. If you want to pass a parameter, you can add it to the command line and use System.Environment.GetCommandLineArgs to retrieve it within the class function.
-
-
DEMO
CD .. \.. \.. Set workspace=%CD%svn up--accept mine-full--forcecd Tools "C:\Program Files (x86) \unity\ Editor\unity.exe "-batchmode-projectpath%workspace%\cb-art-nographics-executemethod Cautoresourcebuilder.productexportall_android -logfile%workspace%\cb-product\buildinfo\ Lastautobuildlog.txt-quit
Resources
Unity3d Command Line Build http://www.cnblogs.com/gameprogram/archive/2012/05/11/2496303.html
Unity Command Line Argument http://docs.unity3d.com/Manual/CommandLineArguments.html
Game Bull Unity User Document command line arguments http://www.unitymanual.com/m/Manual/65.html
Command Line Build Unity Project