美文网首页unity3D技术分享
unity-svn快速更新提交代码

unity-svn快速更新提交代码

作者: 好怕怕 | 来源:发表于2023-11-29 19:56 被阅读0次

    放到Editor文件夹下即可

    using System.Diagnostics;
    using UnityEditor;
    using UnityEngine;
    
    /// <summary>
    /// 快速更新提交的svn工具
    /// </summary>
    public class FUniSVN
    {
        public const string NAME = "SVN/";
        public const int PRIORITY = 1000;
    
        [MenuItem(NAME + "/更新", false, PRIORITY)]
        public static void SVNUpdate()
        {
            string path = Application.dataPath.Replace("Assets", "");
            Process.Start("TortoiseProc.exe", "/command:update /path:" + path + " /closeonend:0");
        }
    
        [MenuItem(NAME + "/提交", false, PRIORITY)]
        public static void SVNCommit()
        {
            SVNCmd("commit", getCurSelectedPath());
        }
    
        [MenuItem(NAME + "/日志", false, PRIORITY)]
        public static void SVNLog()
        {
            SVNCmd("log", getCurSelectedPath());
        }
    
        [MenuItem(NAME + "/还原", false, PRIORITY)]
        public static void SVNRevert()
        {
            SVNCmd("revert", getCurSelectedPath());
        }
    
        [MenuItem(NAME + "/忽略", false, PRIORITY)]
        public static void SVNIgnore()
        {
            SVNCmd("ignore", getCurSelectedPath());
        }
    
        [MenuItem(NAME + "/浏览", false, PRIORITY)]
        public static void SVNRepobrowser()
        {
            SVNCmd("repobrowser", getCurSelectedPath());
        }
    
    
    
        private static string getProjectPath()
        {
            string path = Application.dataPath;
            return path.Substring(0, path.Length - 13);
        }
    
    
        private static string getCurSelectedPath(bool multiPath = true)
        {
            if (!multiPath)
                return Application.dataPath + AssetDatabase.GetAssetPath(Selection.objects[0]).Substring(6);
            string path = "";
            foreach (Object item in Selection.objects)
                path += '*' + Application.dataPath + AssetDatabase.GetAssetPath(item).Substring(6);
            if (path.Length <= 1)
                return Application.dataPath;
            else
                return path.Substring(1);
        }
    
    
        public static void SVNCmd(string cmd, string path)
        {
            Process.Start("TortoiseProc.exe", "/command:" + cmd + " /path:\"" + path + "\" /closeonend:0");
        }
    
    
    
        #region SVN控制
    
    
        [MenuItem(NAME + "/程序提交 _F2")]
        public static void SvnCommitCustom_2()
        {
            Process.Start("TortoiseProc.exe", "/command:commit /path:"
                + Application.dataPath + "/Scripts*"
                + Application.dataPath + "/Editor");
        }
        #endregion
    
    
    
    
    }
    
    

    相关文章

      网友评论

        本文标题:unity-svn快速更新提交代码

        本文链接:https://www.haomeiwen.com/subject/qdpfgdtx.html