├── .gitignore ├── README.md └── SVN └── UnitySVN.cs /.gitignore: -------------------------------------------------------------------------------- 1 | [Ll]ibrary/ 2 | [Tt]emp/ 3 | [Oo]bj/ 4 | [Bb]uild/ 5 | [Bb]uilds/ 6 | Assets/AssetStoreTools* 7 | 8 | # Visual Studio cache directory 9 | .vs/ 10 | 11 | # Autogenerated VS/MD/Consulo solution and project files 12 | ExportedObj/ 13 | .consulo/ 14 | *.csproj 15 | *.unityproj 16 | *.sln 17 | *.suo 18 | *.tmp 19 | *.user 20 | *.userprefs 21 | *.pidb 22 | *.booproj 23 | *.svd 24 | *.pdb 25 | *.opendb 26 | 27 | # Unity3D generated meta files 28 | *.pidb.meta 29 | *.pdb.meta 30 | 31 | # Unity3D Generated File On Crash Reports 32 | sysinfo.txt 33 | 34 | # Builds 35 | *.apk 36 | *.unitypackage 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UnitySVN 2 | 将 TortoiseSVN 的基础操作内嵌到 Unity,并使用快捷键操作,提高效率。这里只是添加了几个常用的操作,其他操作需要的话可以自行添加。具体命令可参见TortoiseSVN的help功能,也可以直接去官网查看相关的命令:https://tortoisesvn.net/docs/nightly/TortoiseSVN_en/tsvn-cli-main.html 3 | 4 | ## 工具介绍: 5 | 1. 将 SVN 文件夹放到 Unity 项目的 Editor 文件夹下即可,在菜单栏的 Assets->SVN 下会显示支持的所有操作 6 | 2. 带 All 的命令是跟整个工程相关的,比如说 CommitAll 是提交整个项目的修改,UpdateAll 是更新整个项目的修改 7 | 3. 不带 All 的命令跟选中的文件或文件夹相关,比如说 Commit 命令需要先选中要提交的文件或者某个文件夹下所有的文件,然后使用 `Alt+C` 快捷键提交选中 8 | 9 | ## 常用流程: 10 | 1. 使用 `Alt+Shift+C` 快捷键更新整个项目 11 | 2. 选中某个改动的文件或者某个文件夹(这个文件加下所有改动过的文件都会执行相应操作),然后使用 `Alt+C` 快捷键提交选中 12 | 3. 其他命令只是在偶尔需要的使用使用,最常用的就两个命令:`Alt+Shift+C` 和 `Alt+C` -------------------------------------------------------------------------------- /SVN/UnitySVN.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * 将 TortoiseSVN 的基础操作内嵌到 Unity,并使用快捷键操作,提高效率。 3 | * 这里只是添加了几个常用的操作,其他操作需要的话可以自行添加。具体命令可参见TortoiseSVN的help功能, 4 | * 也可以直接去官网查看相关的命令:https://tortoisesvn.net/docs/nightly/TortoiseSVN_en/tsvn-cli-main.html 5 | * 6 | * 工具介绍: 7 | * 1. 将 SVN 文件夹放到 Unity 项目的 Editor 文件夹下即可,在菜单栏的 Assets->SVN 下会显示支持的所有操作 8 | * 2. 带 All 的命令是跟整个工程相关的,比如说 CommitAll 是提交整个项目的修改,UpdateAll 是更新整个项目的修改 9 | * 3. 不带 All 的命令跟选中的文件或文件夹相关,比如说 Commit 命令需要先选中要提交的文件或者某个文件夹下所有的文件,然后使用 `Alt+C` 快捷键提交选中 10 | * 11 | * 常用流程: 12 | * 1. 使用 `Alt+Shift+C` 快捷键更新整个项目 13 | * 2. 选中某个改动的文件或者某个文件夹(这个文件加下所有改动过的文件都会执行相应操作),然后使用 `Alt+C` 快捷键提交选中 14 | * 3. 其他命令只是在偶尔需要的使用使用,最常用的就两个命令:`Alt+Shift+C` 和 `Alt+C` 15 | */ 16 | 17 | using UnityEngine; 18 | using UnityEditor; 19 | using System.Diagnostics; 20 | 21 | public class UnitySVN 22 | { 23 | private const string COMMIT = "commit"; 24 | private const string UPDATE = "update"; 25 | private const string LOG = "log"; 26 | 27 | private const string SVN_COMMIT = "Assets/SVN/Commit &c"; 28 | private const string SVN_COMMIT_ALL = "Assets/SVN/CommitAll &#c"; 29 | private const string SVN_UPDATE = "Assets/SVN/Update &u"; 30 | private const string SVN_UPDATE_ALL = "Assets/SVN/UpdateAll &#u"; 31 | private const string SVN_LOG = "Assets/SVN/ShowLog &l"; 32 | private const string SVN_LOG_ALL = "Assets/SVN/ShowLogAll &#l"; 33 | 34 | /// 35 | /// 创建一个SVN的cmd命令 36 | /// 37 | /// 命令(可在help里边查看) 38 | /// 命令激活路径 39 | public static void SVNCommand(string command, string path) 40 | { 41 | //closeonend 2 表示假设提交没错,会自动关闭提交界面返回原工程,详细描述可在 42 | //TortoiseSVN/help/TortoiseSVN/Automating TortoiseSVN里查看 43 | string c = "/c tortoiseproc.exe /command:{0} /path:\"{1}\" /closeonend 2"; 44 | c = string.Format(c, command, path); 45 | ProcessStartInfo info = new ProcessStartInfo("cmd.exe", c); 46 | info.WindowStyle = ProcessWindowStyle.Hidden; 47 | Process.Start(info); 48 | } 49 | /// 50 | /// 提交选中内容 51 | /// 52 | [MenuItem(SVN_COMMIT)] 53 | public static void SVNCommit() 54 | { 55 | SVNCommand(COMMIT, GetSelectedObjectPath()); 56 | } 57 | /// 58 | /// 提交全部Assets文件夹内容 59 | /// 60 | [MenuItem(SVN_COMMIT_ALL)] 61 | public static void SVNCommitAll() 62 | { 63 | SVNCommand(COMMIT, Application.dataPath); 64 | } 65 | /// 66 | /// 更新选中内容 67 | /// 68 | [MenuItem(SVN_UPDATE)] 69 | public static void SVNUpdate() 70 | { 71 | SVNCommand(UPDATE, GetSelectedObjectPath()); 72 | } 73 | /// 74 | /// 更新全部内容 75 | /// 76 | [MenuItem(SVN_UPDATE_ALL)] 77 | public static void SVNUpdateAll() 78 | { 79 | SVNCommand(UPDATE, Application.dataPath); 80 | } 81 | /// 82 | /// 显示更改日志 83 | /// 84 | [MenuItem(SVN_LOG)] 85 | public static void SVNLog() 86 | { 87 | SVNCommand(LOG, GetSelectedObjectPath()); 88 | } 89 | /// 90 | /// 显示所有的更改日志 91 | /// 92 | [MenuItem(SVN_LOG_ALL)] 93 | public static void SVNLogAll() 94 | { 95 | SVNCommand(LOG, Application.dataPath); 96 | } 97 | 98 | /// 99 | /// 获取全部选中物体的路径 100 | /// 包括meta文件 101 | /// 102 | /// 103 | private static string GetSelectedObjectPath() 104 | { 105 | string path = string.Empty; 106 | 107 | for (int i = 0; i < Selection.objects.Length; i++) 108 | { 109 | path += AssetsPathToFilePath(AssetDatabase.GetAssetPath(Selection.objects[i])); 110 | //路径分隔符 111 | path += "*"; 112 | //meta文件 113 | path += AssetsPathToFilePath(AssetDatabase.GetAssetPath(Selection.objects[i])) + ".meta"; 114 | //路径分隔符 115 | path += "*"; 116 | } 117 | 118 | return path; 119 | } 120 | /// 121 | /// 将Assets路径转换为File路径 122 | /// 123 | /// Assets/Editor/... 124 | /// 125 | public static string AssetsPathToFilePath(string path) 126 | { 127 | string m_path = Application.dataPath; 128 | m_path = m_path.Substring(0, m_path.Length - 6); 129 | m_path += path; 130 | 131 | return m_path; 132 | } 133 | 134 | } --------------------------------------------------------------------------------