启动Unity
在macOS上,在终端中键入以下内容以启动Unity:
/Applications/Unity/Unity.app/Contents/MacOS/Unity
在Windows上,在命令提示符中键入以下内容以启动Unity:
"C:\Program Files\Unity\Editor\Unity.exe"
所有命令行表格:https://docs.unity3d.com/Manual/CommandLineArguments.html
例子
项目中的C#脚本:
using UnityEditor;
class MyEditorScript
{
static void PerformBuild ()
{
string[] scenes = { "Assets/MyScene.unity" };
BuildPipeline.BuildPlayer(scenes, ...);
}
}
以下命令以批处理模式执行Unity,执行该MyEditorScript.PerformBuild方法,然后在完成时退出。
视窗:
"C:\Program Files\Unity\Editor\Unity.exe" -quit -batchmode -projectPath "C:\Users\UserName\Documents\MyProject" -executeMethod MyEditorScript.PerformBuild
苹果系统:
/Applications/Unity/Unity.app/Contents/MacOS/Unity -quit -batchmode -projectPath ~/UnityProjects/MyProject -executeMethod MyEditorScript.PerformBuild