c0d3n4m 发表于 2022-4-3 16:44

Unity 命令行

1 运行程序,先cmd进入相应的unity 版本的安装目录下的Editor文件夹下。

1.1 unity.exe -projectPath xxx 打开xxx路径程序

1.2 unity.exe-buildTarget iOS 切换平台等等

1.3 unity xxx -executeMethod xxx.xx 调用程序的xx类的xx方法 方法必须是静态的,类必须要放在Editor下

1.4 unity -quit xxxx..... 是执行完完退出程序

1.5 重要点   GetCommandLineArgs

如何传递参数 其实很简单 直接在 后面跟上GetCommandLineArgs xxx参数就可

但是在unity中要用响应的方法接收

   String[] arguments= Environment.GetCommandLineArgs();

arguments []数组就是传递 的参数,

完整的例子:

unity.exe -quit -projectPath XXX -buildTarget Win64 -executeMethod 类名. 方法名 GetCommandLineArgs android

XXX是项目路径
页: [1]
查看完整版本: Unity 命令行