Unity游戏开发—SVN工具集成
0.前言
对于小型游戏团队来说,SVN应该是团队协作工具的首选,因为他上手简单,对于不懂程序的其他成员来说,学习难度较低,但是每次提交、更新都需要从Unity切换到文件夹,个人感觉比较繁琐,所以在此分享一个集成到Unity中的SVN菜单工具,这样团队所有人都可以无门槛使用,并且节省很多时间了。
1.具体实现
using Boo.Lang;
using UnityEditor;
using UnityEngine;
public class SVNTool : Editor
[MenuItem("SVN/提交",false,1)]
static void SVNCommit(){
List<string> pathList = new List<string> ();
string basePath = SVNProjectPath + "/Assets";
pathList.Add (basePath);
pathList.Add (SVNProjectPath+"/ProjectSettings");
string commitPath = string.Join ("*", pathList.ToArray ());
ProcessCommand ("TortoiseProc.exe", "/command:commit /path:"+ commitPath);
[MenuItem("SVN/更新",false,2)]
static void SVNUpdate(){
ProcessCommand ("TortoiseProc.exe", "/command:update /path:" + SVNProjectPath + " /closeonend:0");
[MenuItem("SVN/", false, 3)]
static void Breaker () { }
[MenuItem("SVN/清理缓存",false,4)]
static void SVNCleanUp(){
ProcessCommand ("TortoiseProc.exe", "/command:cleanup /path:" + SVNProjectPath);
[MenuItem("SVN/打开日志",false,5)]
static void SVNLog(){
ProcessCommand ("TortoiseProc.exe", "/command:log /path:" + SVNProjectPath);
static string SVNProjectPath{
get{
System.IO.DirectoryInfo parent = System.IO.Directory.GetParent(Application.dataPath);
return parent.ToString();
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;
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);