Unity 命令行
2022-04-02 本文已影响0人
呢喃_0412
1 运行程序,先cmd进入相应的unity 版本的安装目录下的Editor文件夹下。
![](https://img.haomeiwen.com/i12323620/5e3c397b7808e3ea.png)
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是项目路径