【Unity】svn一键提交,更新
可以在Unity内一键更新,不用再去文件夹点右键提交更新了using System;using System.Diagnostics;using System.IO;using UnityEditor;using UnityEngine;namespace SVNTool{ public class SvnEditor : EditorWindow { #region Setup private const string Svnkey = "key_svnroot"; private const string SvnName = "TortoiseProc.exe"; private static string s_svnpath = SvnName; public static void Setup() { GetWindow<SvnEditor>(); } #endregion #region Log public static void SVNLogAll() { SvnCmdProject(EmSVNCmd.Log); } public static void SVNLog() { SvnCmdSelect(EmSVNCmd.Log); } #endregion #region Update public static void SVNUpdate() { SvnCmdSelect(EmSVNCmd.Update); } public static void SVNUpdateAll() { SvnCmdProject(EmSVNCmd.Update); } #endregion #region Commit public static void SVNCommitAll() { SvnCmdProject(EmSVNCmd.Commit); } public static void SVNCommit() { SvnCmdSelect(EmSVNCmd.Commit); } #endregion #region Revert public static void SVNRevert() { SvnCmdSelect(EmSVNCmd.Revert); } #endregion #region Clearup public static void SVNClearUpAll() { SvnCmdProject(EmSVNCmd.Clearup); } #endregion #region core private static void SvnCmdProject(EmSVNCmd cmd) { var path = Application.dataPath; var project = Directory.GetParent(path); ProcessStart(cmd, project.FullName); } private static void SvnCmdSelect(EmSVNCmd cmd) { var select = Selection.activeObject; var path = AssetDatabase.GetAssetPath(select); ProcessStart(cmd, path); } private static void ProcessStart(EmSVNCmd cmd, string path) {#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN try { var info = new ProcessStartInfo(s_svnpath) { Arguments = string.Format("/command:{0} /path:{1} /closeonend:0", cmd.ToString().ToLower(), path) }; Process.Start(info); } catch (Exception) { Setup(); }#endif } #endregion internal void OnEnable() { s_svnpath = EditorPrefs.GetString(Svnkey); } internal void OnGUI() { EditorGUILayout.LabelField("设置SVN"); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("SVN程序", GUILayout.Width(50)); EditorGUILayout.SelectableLabel(s_svnpath, GUILayout.Width(200)); if (GUILayout.Button("select")) { var path = EditorUtility.OpenFilePanel("请选择TortoiseProc.exe存储位置", "", "exe"); if (string.IsNullOrEmpty(path)) return; s_svnpath = path; EditorPrefs.SetString(Svnkey, s_svnpath); } if (GUILayout.Button("Clear")) { s_svnpath = SvnName; EditorPrefs.SetString(Svnkey, s_svnpath); } EditorGUILayout.EndHorizontal(); } private enum EmSVNCmd { Log, Update, Commit, Revert, Clearup } }}
页:
[1]