使用快捷键
ctrl+shift+q 上传
Ctrl+shift+w 更新
目标目录:Asset、ProjectSetting
#if UNITY_EDITOR
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class SVNControl : MonoBehaviour
{
public static string EXE = "TortoiseProc.exe";
//svn项目根目录即 .svn文件所在目录
public static string SVNProjectPath = System.Environment.CurrentDirectory;
//svn项目根地址
public static string SVNIP = "";
[MenuItem("Tools/SVN/Commit %#q")]
public static void SVNCommit()
{
List<string> pathList = new List<string>();
// Debug.LogError(SVNProjectPath);
string basePath = SVNProjectPath + "/Assets";
pathList.Add(basePath);
pathList.Add(SVNProjectPath + "/ProjectSettings");
string commitPath = string.Join("*", pathList.ToArray());
ProcessCommand(EXE, "/command:commit /path:" + commitPath);
}
[MenuItem("Tools/SVN/Update %#w")]
public static void SVNUpdate()
{
ProcessCommand(EXE, "/command:update /path:" + SVNProjectPath);
}
public static void ProcessCommand(string command, string argument)
{
System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo(command);
info.Arguments = argument;
info.CreateNoWindow = true;
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();
}
}
#endif