为了方便开发时更新资源,可以做一些简化操作的小工具,提高效率。 由于项目中采用的是SVN来进行版本控制,所以我这里是加入了svn更新和提交文件的小工具。
using System.Collections.Generic;
using System.IO;
using UnityEditor;
public class SVNUtils
{
private static List<string> drives = new List<string>() { "C:", "D:", "E:", "F:" };
private static string svnPath = @"\Program Files\TortoiseSVN\bin\";
private static string svnProc = @"TortoiseProc.exe";
private static string svnProcPath = "";
private static string Path_SVNProject = "E:/SVNProjectName";
private static string Path_Protocol = "E:/Protocol";
private static string Path_Design = "E:/Design";
private static string Path_ArtUI = "E:/ArtUI";
[MenuItem("Tools/SVN/更新/代码")]
private static void UpdateSVNProject()
{
UpdateFromSVN(Path_SVNProject);
}
[MenuItem("Tools/SVN/更新/协议")]
private static void UpdateProtocol()
{
UpdateFromSVN(Path_Protocol);
}
[MenuItem("Tools/SVN/更新/配置")]
private static void UpdateDesign()
{
UpdateFromSVN(Path_Design);
}
[MenuItem("Tools/SVN/更新/UI")]
private static void UpdateArtUI()
{
UpdateFromSVN(Path_ArtUI);
}
[MenuItem("Tools/SVN/更新/全部(代码、协议、配置、UI)")]
private static void UpdateAll()
{
UpdateFromSVN(Path_SVNProject);
UpdateFromSVN(Path_ArtUI);
UpdateFromSVN(Path_Design);
UpdateFromSVN(Path_Protocol);
}
private static void UpdateFromSVN(string localFolderPath)
{
if (string.IsNullOrEmpty(svnProcPath)) svnProcPath = GetSvnProcPath();
string updatePath = localFolderPath.Replace("/", "\\");
string updateCall = "/command:update /path:" + "\"" + updatePath + "\"" + "/closeonend:0";
System.Diagnostics.Process.Start(svnProcPath, updateCall);
}
[MenuItem("Tools/SVN/提交/代码")]
private static void UpdateCommitProject()
{
CommitToSVN(Path_SVNProject, "代码");
}
[MenuItem("Tools/SVN/提交/协议")]
private static void UpdateCommitProtocol()
{
CommitToSVN(Path_Protocol, "协议");
}
[MenuItem("Tools/SVN/提交/配置")]
private static void UpdateCommitDesign()
{
CommitToSVN(Path_Design, "配置");
}
[MenuItem("Tools/SVN/提交/UI")]
private static void UpdateCommitArtUI()
{
CommitToSVN(Path_ArtUI, "UI");
}
private static void CommitToSVN(string localFolderPath, string commitMsgTip)
{
if (string.IsNullOrEmpty(svnProcPath)) svnProcPath = GetSvnProcPath();
string updatePath = localFolderPath.Replace("/", "\\");
string updateCall = "/command:commit /path:" + "\"" + updatePath + "\"" + "/logmsg:" + commitMsgTip + " /closeonend:0";
System.Diagnostics.Process.Start(svnProcPath, updateCall);
}
private static string GetSvnProcPath()
{
foreach (string item in drives)
{
string path = string.Concat(item, svnPath, svnProc);
if (File.Exists(path))
{
return path;
}
}
return EditorUtility.OpenFilePanel("Select TortoiseProc.exe", "C:\\", "exe");
}
}
|