【unity小技巧之二】使用unity3d调用命令行工具

本文介绍了一种在Unity编辑器中实现一键自动更新SVN的方法。通过编写简单的C#脚本来调用SVN命令行工具,使得策划等非技术人员也能方便地进行版本更新操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

有时候策划经常把不该提交的东西提交上去!

有的时候想在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();
	}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

鱼蛋-Felix

如果对你有用,可以请我喝杯可乐

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值