有时候策划经常把不该提交的东西提交上去!
有的时候想在Unity中点击一个按钮就自动更新/提交SVN!
等等....
调用命令行工具即可实现,代码如下:
System.IO.DirectoryInfo parent = System.IO.Directory.GetParent(Application.dataPath);
string projectPath=parent.ToString();
ProcessCommand ("svn", "update\""+projectPath+"\"");
public static void ProcessCommand(string command,string argument){
System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo(command);
info.Arguments = argument;
info.CreateNoWindow = false;
info.ErrorDialog = true;
info.UseShellExecute = true;
if(info.UseShellExecute){
info.RedirectStandardOutput = false;
info.RedirectStandardError = false;
info.RedirectStandardInput = false;
} else{
info.RedirectStandardOutput = true;
info.RedirectStandardError = true;
info.RedirectStandardInput = true;
info.StandardOutputEncoding = System.Text.UTF8Encoding.UTF8;
info.StandardErrorEncoding = System.Text.UTF8Encoding.UTF8;
}
System.Diagnostics.Process process = System.Diagnostics.Process.Start(info);
if(!info.UseShellExecute){
Debug.Log(process.StandardOutput);
Debug.Log(process.StandardError);
}
process.WaitForExit();
process.Close();
}