Unity3D 命令行参数

@by 广州小龙                                              unity ios开发群:63438968

Typically, Unity will be launched by double-clicking its icon from the desktop but it is also possible to run it from the command line (ie, the MacOS Terminal or the Windows Command Prompt). When launched in this way, Unity can receive commands and information on startup, which can be very useful for test suites, automated builds and other production tasks.

通常情况下,Unity可以通过双击桌面上的图标启动,也可以通过输入命令行启动(例如,MacOS终端或者Windows的CMD窗口),通过这种方式在启动时会接受命令和信息,这对测试对象,自动生成和其他制作任务是非常有用的。

Under MacOS, you can launch Unity from the Terminal by typing:-

在MacOs中,你可以在终端输入以下命令来启动Unity

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

...while under Windows, you should type

在windows下,你可以在CMD中输入

"C:\Program Files (x86)\Unity\Editor\Unity.exe"

...at the command prompt. ......在命令提示符下。

Standalone Unity games can be launched in a similar way.

也可以用类似的方式启动单独的Unity游戏

Command Line Arguments 命令行参数

As mentioned above, the editor and also built games can optionally be supplied with additional commands and information on startup. This is done using the following command line arguments:-

如上所述,编辑器和建立游戏也能在启动时选择性的提供额外的命令和信息。这是使用下面的命令行参数:

-batchmode
Run Unity in 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 return code 1. Note that in batch mode, Unity will send a minimal version of its log output to the console. However, the Log Files still contain the full log information.

批处理模式下运行Unity。应始终与其他命令行参数一起使用,因为它确保不会弹出窗口,无需任何人为的干预。当脚本代码在执行过程中发生异常,资源服务
器更新失败或其他操作失败时Unity将立即退出,并返回代码为1。请注意,在批处理模式下,
Unity将向控制台发送输出版本最小的日志。当然,日志文件将包含完整的日志信息。
-quit
Quit
the Unity editor after other commands have finished executing. Note
that this can cause error messages to be hidden (but they will show up
in the Editor.log file).
其他命令执行完毕后将退出Unity编辑器。请注意,这可能会导致错误消息被隐藏(但他们将显示在Editor.log文件)
-buildWindowsPlayer <pathname>
Build a standalone Windows player (eg, -buildWindowsPlayer path/to/your/build.exe).
建立一个单独的Windows游戏(例如:-buildWindowsPlayer path/to/your/build.exe)
-buildOSXPlayer <pathname>
Build a standalone Mac OSX player (eg, -buildOSXPlayer path/to/your/build.app).
建立Mac游戏(例如:-buildOSXPlayer path/to/your/build.app)
-importPackage <pathname>
Import the given package. No import dialog is shown.
导入提供的package,不会显示导入对话框
-createProject <pathname>
Create an empty project at the given path.
根据提供的路径建立一个空项目
-projectPath <pathname>
Open the project at the given path.
打开指定路径的项目
-logFile <pathname>
Specify where the Editor log file will be written.
指定将要被写入编辑的log文件
-assetServerUpdate <IP[:port] projectName username password [r <revision>]>
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
to ensure you are working with the correct project. If 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.

通过ip端口强制更新资源服务器的项目。端口是可选的,如果不是的话可以假定一个标准端口(10733)。最好使用此命令配合-
projectpath参数确保你在正确的项目里工作。如果没有提供项目名字是那么就是最后一个Unity打开的项目。如果没有选择项目的路径则由-
projectpath自动创建。
-exportPackage <exportAssetPath exportFileName>
Exports
a package given a path. exportAssetPath is a folder (relative to to the
Unity project root) to export from the Unity project and exportFileName
is the package name. Currently, this option can only export a whole
folder at a time. This command normally needs to be used with the
-projectPath argument.

据路径导出package。exportAssetPath是一个文件夹(相对Unity项目的根目录)为了导出Unity项目并且
exportFileName是package的名称。目前,此选项只能在同一个时间导出整个文件夹。这个命令通常需要使用-
projectpath参数
-nographics (Windows only)
When
running in batch mode, do not initialize graphics device at all. This
makes it possible to run your automated workflows on machines that don't
even have a GPU.
当运行在批处理模式,不会初始化显卡设备。这使得它可以在你的机器上自动按工作流程运行,甚至它没有GPU。
-executeMethod <ClassName.MethodName>
Execute
the static method as soon as Unity is started, the project is open and
after the optional asset server update has been performed. This can be
used to do continous integration, perform Unit Tests, make builds,
prepare some data, etc. If you want to return an error from the
commandline process you can either throw an exception which will cause
Unity to exit with 1 or else call EditorApplication.Exit with a non-zero code. 

Unity启动的同时会执行静态方法,该项目是开放的并且是在可选资源服务器更新完成之后。这可以用来不断的整合,进行单元测试,制作模型,准备一些数据
等。如果你想通过命令行返回一个错误,你可以抛出一个异常,会引发代码为1的Unity关闭或其他引发EditorApplication.Exit非零
代码。

To use -executeMethod you need to have a script in an Editor folder and a static function in the class.

使用executeMethod,你需要在编辑文件夹有一个脚本并且类里有一个静态函数。

// C# exampleusingUnityEditor;classMyEditorScript{staticvoidPerformBuild(){string[] scenes ={"Assets/MyScene.unity"};BuildPipeline.BuildPlayer(scenes,...);}}
// JavaScript examplestaticvoidPerformBuild(){string[] scenes ={"Assets/MyScene.unity"};BuildPipeline.BuildPlayer(scenes,...);}

Example usage 用法示例

Execute Unity in batch mode, execute MyEditorScript.MyMethod method, and quit upon completion.

在批处理模式下执行Unity,执行MyEditorScript.MyMethod方法,完成后退出。

Windows:
C:\program files\Unity\Editor>Unity.exe -quit -batchmode -executeMethod MyEditorScript.MyMethod

Mac OS:
/Applications/Unity/Unity.app/Contents/MacOS/Unity -quit -batchmode -executeMethod MyEditorScript.MyMethod

Execute
Unity in batch mode. 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.

在批处理模式下执行Unity。使用给定的项目路径和从资源服务器上进行更新。在所有资源已被下载且从资源服务器导入后执行给定的方法。当执行的方法完成后会自动退出Unity。

/Applications/Unity/Unity.app/Contents/MacOS/Unity
-batchmode -projectPath ~/UnityProjects/AutobuildProject
-assetServerUpdate 192.168.1.1 MyGame AutobuildUser l33tpa33
-executeMethod MyEditorScript.PerformBuild -quit

Unity Standalone Player command line arguments
Unity 独立版游戏命令行参数

Standalone players built with Unity also understand some command line arguments:

Unity创建独立版游戏也要了解一些命令行参数:

-batchmode
Run
the game in "headless" mode. The game will not display anything or
accept user input. This is mostly useful for running servers for networked games.
在"headless"模式下运行游戏。游戏将不显示任何内容,或接受用户输入。这对运行网络游戏的服务器有很大的作用的。
-force-opengl (Windows only)
Make
the game use OpenGL for rendering, even if Direct3D is available.
Normally Direct3D is used but OpenGL is used if Direct3D 9.0c is not
available.
让游戏使用OpenGL进行渲染,即使有可用的Direct3D。通常情况是使用Direct3D,但如果是Direct3D 9.0c的不可用的话则会选用OpenGL。
-single-instance (Windows only)
Allow
only one instance of the game to run at the time. If another instance
is already running then launching it again with -single-instance will
just focus the existing one.
在同一时候只允许一个游戏实例运行。如果另一个实例已在运行,然后再次通过 -single-instance启动它的话会调节到现有的这个实例。
-nolog (Windows only)
Do not produce output log. Normally output_log.txt is written in the *_Data folder next to the game executable, where Debug.Log output is printed.
不产生输出日志。 通常output_log.txt被写在游戏输出目录下的*_Data文件夹中 ,在debug.log中打印输出的地方。
-force-d3d9-ref (Windows only)
Make the game run using Direct3D's "Reference" software renderer. The DirectX SDK has
to be installed for this to work. This is mostly useful for building
automated test suites, where you want to ensure rendering is exactly the
same no matter what graphics card is being used.
使游戏运行在Direct3D的"Reference"软件渲染模式,必须要安装DirectX SDK才能使其工作。这主要是用于建立自动化测试对象,这样您可以确保不管是使用什么显卡,其渲染效果是完全一样的。
-adapter N (Windows only)
Allows the game to run full-screen on another display, where N denotes the display number.
允许游戏全屏运行在另一台显示器上,其中N表示显示的号码。
-popupwindow (Windows only)
The window will be created as a a pop-up window (without a frame). 
这个窗口将以弹出的方式创建(没有框架)

Unity3D 命令行参数的更多相关文章

  1. python处理命令行参数

    直接从命令行执行py文件的时候如果带有参数,如何获取这些参数,如何解析? http://blog.chinaunix.net/uid-20786165-id-3182268.html sys.argv ...

  2. .NET Core采用的全新配置系统[5]: 聊聊默认支持的各种配置源[内存变量,环境变量和命令行参数]

    较之传统通过App.config和Web.config这两个XML文件承载的配置系统,.NET Core采用的这个全新的配置模型的最大一个优势就是针对多种不同配置源的支持.我们可以将内存变量.命令行参 ...

  3. Shell特殊变量:Shell $0, $#, $*, $@, $?, $$和命令行参数

    特殊变量列表 变量 含义 $0 当前脚本的文件名 $n 传递给脚本或函数的参数.n 是一个数字,表示第几个参数.例如,第一个参数是$1,第二个参数是$2. $# 传递给脚本或函数的参数个数. $* 传 ...

  4. powershell脚本,命令行参数传值,并绑定变量的例子

    这是小技巧文章,所以文章不长.但原创唯一,非常重要.我搜了下,还真没有人发 powershell怎样 [命令行 参数 绑定],所以我决定写成博客. 搜索关键字如下: powershell 命令行 参数 ...

  5. VS2013 带命令行参数的调试问题 解决方案

    int main(int argc,char* argv[]) argc是命令行总的参数个数,argv[]是argc个参数,其中第0个参数是程序的全名,以后的参数命令行后面跟的用户输入的参数 比如:  ...

  6. 使用getopt()处理命令行参数

    假设有一程序 testopt,其命令行选项参数有: -i            选项 -l            选项 -r           选项 -n <值> 带关联值的选项 则处理 ...

  7. 7z命令行参数中的路径

    最近在自动化的过程中用到了7z命令行工具,发现其参数中的路径挺有意思的,在此总结一下.本文中所有demo使用的7z版本为:15.14 x64. 压缩某个文件夹 下面的命令会把g:\temp\目录和目录 ...

  8. [转]Python 命令行参数和getopt模块详解

    FROM : http://www.tuicool.com/articles/jaqQvq 有时候我们需要写一些脚本处理一些任务,这时候往往需要提供一些命令行参数,根据不同参数进行不同的处理,在Pyt ...

  9. 你可能不知道的Google Chrome命令行参数

    概述:              关于Google Chrome命令行参数(英文叫Google Chrome Command line switches),是Chrome为了实现实验性功能.方便调试. ...

随机推荐

  1. 从零開始开发Android版2048 (一)初始化界面

    自学Android一个月多了,一直在工作之余零零散散地看一些东西.感觉经常使用的东西都有些了解了,可是一開始写代码总会出各种奇葩的问题.感觉还是代码写得太少.这样继续杂乱地学习下去进度也太慢了,并且学 ...

  2. SSH公钥(public key)验证

    安全的设置服务器 登陆,之前用用户名和密码登陆服务器 这样不安全 ,用SSH公钥(public key)验证  这个办法能很好的解决 登陆服务器 和安全登陆服务器 的特点: 目标: Client 免输 ...

  3. Eclipse项目 迁移到 Intellj IDEA

    自从用了Intellj IDEA,很多项目都想迁移到Intellj上面去开发  鉴于我们的大部分项目都是基于Maven构建的,所以就可以利用maven的命令来做这个事情.     1.选择一个ecli ...

  4. python基础知识六

    博客园的博文对每篇博文的长度似乎做了限制 面向对象编程, 在程序何种,根据操作数据的函数或语句块来设计程序.这被成为面向过程的编程.还有一种把数据和功能结合起来,用称为对象的东西包裹起来组织组织程序的 ...

  5. onTextChanged参数解释及实现EditText字数监听

    http://www.picksomething.cn/?p=34 由于最近做项目要检测EditText中输入的字数长度,从而接触到了Android中EditText的监听接口,TextWatcher ...

  6. ubuntu下配置java环境变量

    1.官网下载linux对应的jdk安装包tar.gz 2.filezilla上传tar.gz到对应ubuntu目录test下(见上一篇) 3.解压:tar -zcvf XXX.tar.gz 4.修改解 ...

  7. jvm - 内存结构以其解析

    可以将jvm粗略分为以下部分: Heap Memory:存储java对象. Non-Heap Memory:存储加载的class文件,以及其他meta-data信息. Other:存储java代码,j ...

  8. Object To Enum

    public static T ObjectToEnum<T>(object o) { try { return (T)Enum.Parse(typeof(T), o.ToString() ...

  9. iOS8 iPad Warning: Attempt to present <UIImagePickerController:xxxx > on xxxx which is already presenting (null)

    解决方法: /* I think this is because in iOS 8, alert views and action sheets are actually presented view ...

  10. CSS 尺寸 (Dimension)

    CSS 尺寸 (Dimension) 属性允许你控制元素的高度和宽度.同样,它允许你增加行间距. 更多实例 设置元素的高度 这个例子演示了如何设置不同元素的高度. 使用百分比设置图像的高度 这个例子演 ...