【IOS】添加IOS执行命令行的工具代码
parent
8df851509f
commit
ab339f2b37
|
@ -55,6 +55,39 @@ namespace GameEditor.Util
|
|||
}
|
||||
public static void ProcessCommand(string dir, string[] coms, bool isShowWindow = false)
|
||||
{
|
||||
#if UNITY_IOS
|
||||
string shellPath = Path.Combine(dir, "coms.shell");
|
||||
if (!File.Exists(shellPath))
|
||||
{
|
||||
File.Create(shellPath).Close();
|
||||
}
|
||||
File.WriteAllLines(shellPath, coms);
|
||||
|
||||
System.Diagnostics.Process p = new System.Diagnostics.Process();
|
||||
//设置要启动的应用程序
|
||||
p.StartInfo.FileName = "/bin/bash";
|
||||
//是否使用操作系统shell启动
|
||||
p.StartInfo.UseShellExecute = false;
|
||||
//接受来自调用程序的输入信息
|
||||
p.StartInfo.RedirectStandardInput = false;
|
||||
//输出信息
|
||||
p.StartInfo.RedirectStandardOutput = false;
|
||||
//输出错误
|
||||
p.StartInfo.RedirectStandardError = false;
|
||||
//不显示程序窗口
|
||||
p.StartInfo.CreateNoWindow = !isShowWindow;
|
||||
//设置文件夹
|
||||
p.StartInfo.WorkingDirectory = dir;
|
||||
p.StartInfo.Arguments = shellPath;
|
||||
//启动程序
|
||||
p.Start();
|
||||
//等待程序执行完退出进程
|
||||
p.WaitForExit();
|
||||
//关闭
|
||||
p.Close();
|
||||
//删除命令行文件
|
||||
File.Delete(shellPath);
|
||||
#else
|
||||
System.Diagnostics.Process p = new System.Diagnostics.Process();
|
||||
//设置要启动的应用程序
|
||||
p.StartInfo.FileName = "cmd.exe";
|
||||
|
@ -86,6 +119,7 @@ namespace GameEditor.Util
|
|||
//等待程序执行完退出进程
|
||||
//p.WaitForExit();
|
||||
p.Close();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue