命令行给unity传参
windows命令行与sh语法区别很大,注意下
.bat脚本
@echo on set UNITY3D_PROJECT_PATH=d:\happyGit\stareditor set UNITY3D_BUILD_METHOD=Build.Test echo %UNITY3D_PROJECT_PATH% D:\soft\Unity\Editor\2019.3.13f1\Editor\Unity.exe -quit -batchmode -executeMethod %UNITY3D_BUILD_METHOD% -projectPath %UNITY3D_PROJECT_PATH% -logFile D:\build.log -uuu: something pause
用空格区别参数
unity c#
public static void Test()
{
string[] strs = System.Environment.GetCommandLineArgs();
IoBuffer bi = new IoBuffer();
foreach (var s in strs)
{
bi.PutString(s);
if (s.Contains("-uuu:"))
{
///string arg = s.Split(':')[1];
//处理参数//
Debug.Log("gogogogogo--->s:"+s);
string a = "tx";
}
}
byte[] bs = bi.ToArray();
WriteBytes2File("d://testCmd.txt", bs);
bi.Clear();
}
string[] strs = System.Environment.GetCommandLineArgs();
获取到的就是
-quit
-batchmode
-executeMethod
%UNITY3D_BUILD_METHOD%
-projectPath
%UNITY3D_PROJECT_PATH%
-logFile
D:\build.log
-uuu:
something
另外生成的log build.log中可以看到c#的log

浙公网安备 33010602011771号