資源簡介
在Unity中快速使用svn的小工具。
從此不用只是在打開文件夾后去做svn操作,而可以在unity環境下點擊文件右鍵直接操作svn。

代碼片段和文件信息
using?UnityEngine;
using?UnityEditor;
using?System.Collections;
///?
///?Unity?Svn?工具
///?參考:?http://www.cnblogs.com/me115/archive/2011/05/31/2064047.html?
///?官網:http://tortoisesvn.net/docs/release/TortoiseSVN_zh_CN/tsvn-automation.html?
///?
public?class?MiniSvn
{
????#region?-?SVN?-
????[MenuItem(“Assets/SVN/showlog“)]
????static?void?ExternalSvnShowLog()
????{
????????SvnShowLog(GetCurProjectObjPath());
????}
????[MenuItem(“Assets/SVN/add“)]
????static?void?ExternalSvnAdd()
????{
????????SvnAdd(GetCurProjectObjPath());
????}
????[MenuItem(“Assets/SVN/commit“)]
????static?void?ExternalSvnCommit()
????{
????????SvnCommit(GetCurProjectObjPath());
????}
????[MenuItem(“Assets/SVN/update“)]
????static?void?ExternalSvnUpdate()
????{
????????SvnUpdate(GetCurProjectObjPath());
????}
????static?string?GetCurProjectObjPath()
????{
????????if?(null?==?Selection.objects?||?Selection.objects.Length?!=?1)?return?string.Empty;
????????string?path?=?AssetDatabase.GetAssetPath(Selection.objects[0].GetInstanceID());
????????if?(!string.IsNullOrEmpty(path))
????????{
????????????path?=?System.IO.Path.GetFullPath(path);
????????}
????????return?path;
????}
????#endregion
????private?const?string?SVN_EXE_PATH?=?“C:\\Program?Files\\TortoiseSVN\\bin\\TortoiseProc.exe“;
????public?static?void?SvnShowLog(string?filePath)
????{
????????string?args?=?“/command:log?/path:“?+?filePath?+?“?/closeonend:0“;
????????//?快捷方式
????????System.Diagnostics.Process.Start(SVN_EXE_PATH?args);
????????//?cmd方式
????????//string[]?cmdArray?=?new?string[]
????????//{
????????//????“cd?C:\\Program?Files\\TortoiseSVN\\bin\\“
????????//????“TortoiseProc.exe“?+?“?“?+?args
????????//};
????????//RunCmd(cmdArray);
????}
????public?static?void?SvnAdd(string?filePath)
????{
????????string?addRes?=?filePath;
????????if?(System.IO.File.Exists(filePath))
????????{
????????????addRes?=?System.IO.Path.GetDirectoryName(filePath);
????????}
????????string?args?=?“/command:add?/path:“?+?addRes?+?“?/closeonend:0“;
????????System.Diagnostics.Process.Start(SVN_EXE_PATH?args);
????}
????public?static?void?SvnCommit(string?filePath)
????{
????????string?args?=?“/command:commit?/path:“?+?filePath?+?“?/logmsg:res:?ui“?+?“?/closeonend:0“;
????????System.Diagnostics.Process.Start(SVN_EXE_PATH?args);
????}
????public?static?void?SvnUpdate(string?filePath)
????{
????????string?args?=?“/command:update?/path:“?+?filePath?+?“?/closeonend:0“;
????????System.Diagnostics.Process.Start(SVN_EXE_PATH?args);
????}
????private?static?void?RunCmd(string[]?cmds)
????{
????????System.Diagnostics.Process?proc?=?new?System.Diagnostics.Process();
????????proc.StartInfo.CreateNoWindow?=?true;
????????proc.StartInfo.FileName?=?“cmd.exe“;
????????proc.StartInfo.UseShellExecute?=?false;
????????proc.StartInfo.RedirectStandardError?=?true;
????????proc.StartInfo.RedirectStandardInput
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2015-07-07?10:39??Unity?Svn?工具\
?????文件????????3287??2015-07-07?10:37??Unity?Svn?工具\MiniSvn.cs
?????文件?????????178??2015-07-07?10:07??Unity?Svn?工具\MiniSvn.cs.me
- 上一篇:Unity下調用攝像頭識別二維碼
- 下一篇:MSP430簡易示波器
評論
共有 條評論