当前位置: 首页 > news >正文

Unity扩展SVN命令

可以直接在unity里右键文件提交和查看提交记录
在这里插入图片描述
顶部菜单栏上回退和更新整个unity工程
在这里插入图片描述
SvnForUnity.CS
记得要放在Editor文件夹下

using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using UnityEditor;
using UnityEngine;
using Debug = UnityEngine.Debug;public class SvnForUnity
{static string SVN_BASE = Application.dataPath.Replace("/", "\\").Remove(Application.dataPath.Replace("/", "\\").Length - 6, 6);/// <summary>/// 调用cmd命令/// </summary>/// <param name="command">cmd命令</param>/// <param name="argument">命令参数</param>private static void ProcessCommand(string command, string argument){ProcessStartInfo start = new ProcessStartInfo(command){Arguments = argument,CreateNoWindow = false,ErrorDialog = true,UseShellExecute = true//明确传入的执行文件类型};if (start.UseShellExecute){start.RedirectStandardOutput = false;start.RedirectStandardError = false;start.RedirectStandardInput = false;}else{start.RedirectStandardOutput = true;start.RedirectStandardError = true;start.RedirectStandardInput = true;start.StandardOutputEncoding = System.Text.Encoding.UTF8;start.StandardErrorEncoding = System.Text.Encoding.UTF8;}Process p = Process.Start(start);p.WaitForExit();p.Close();}static string MetaFile(string str){return str + ".meta";}static string GetSelectFilePath(){var selectAssets = Selection.GetFiltered<Object>(SelectionMode.Assets);if (selectAssets.Length > 0){string selectionPath = string.Empty;for (int i = 0; i < selectAssets.Length; i++){// Debug.Log(AssetDatabase.GetAssetPath(selectAssets[i]));if (AssetDatabase.GetAssetPath(selectAssets[i]) == "Assets"){return SVN_BASE + "Assets" + "\"";}if (i > 0){selectionPath = selectionPath + "*" + SVN_BASE + AssetDatabase.GetAssetPath(selectAssets[i]).Replace("/", "\\");selectionPath = selectionPath + "*" + SVN_BASE + MetaFile(AssetDatabase.GetAssetPath(selectAssets[i])).Replace("/", "\\");}else{selectionPath = SVN_BASE + AssetDatabase.GetAssetPath(selectAssets[i]).Replace("/", "\\");selectionPath = selectionPath + "*" + SVN_BASE + MetaFile(AssetDatabase.GetAssetPath(selectAssets[i])).Replace("/", "\\");}}return selectionPath  + "\"";}return SVN_BASE + "Assets" + "\"";}/// <summary>/// SVN更新/// </summary>[MenuItem("SVN/Update", false, 1)]public static void SvnUpdate(){ProcessCommand("TortoiseProc.exe", "/command:update /path:\"" + SVN_BASE + "Assets" + "\"");}/// <summary>/// SVN提交/// </summary>[MenuItem("Assets/SVN/Commit", false, 2)]public static void SvnCommit(){var selectPath = GetSelectFilePath();ProcessCommand("TortoiseProc.exe", "/command:commit /path:\"" + selectPath);}/// <summary>/// SVN回退/// </summary>[MenuItem("SVN/Revert", false, 3)]public static void SvnRevert(){ProcessCommand("TortoiseProc.exe", "/command:revert /path:\"" + SVN_BASE + "Assets" + "\"");}/// <summary>/// SVN显示信息/// </summary>[MenuItem("Assets/SVN/ShowLog", false, 4)]public static void SvnLog(){var selectPath = GetSelectFilePath();ProcessCommand("TortoiseProc.exe", "/command:log /path:\"" + selectPath);}
}

参考
https://blog.csdn.net/egostudio/article/details/51074814

http://www.lryc.cn/news/403392.html

相关文章:

  • 「实战应用」如何用DHTMLX将上下文菜单集成到JavaScript甘特图中(三)
  • 微服务保护
  • Python语言的优势所在
  • npm install时报错 reason: certificate has expired
  • 价格战再起:OpenAI 发布更便宜、更智能的 GPT-4o Mini 模型|TodayAI
  • 从0开始对时间序列模型ACF和PACF的理解(以股价预测为例子)
  • MybatisPlus(MP)基础知识全解析
  • 前端组件化实践:Vue自定义加载Loading组件的设计与实现
  • LLaMA 背景
  • 硅谷裸机云多IP服务器怎么样?
  • Python+Django+MySQL的新闻发布管理系统【附源码,运行简单】
  • 实战项目:仿muduo库实现并发服务器
  • 提高Java程序效率:ImmutableList、Stream API 和 JSON序列化实战指南
  • [CP_AUTOSAR]_分层软件架构_接口之通信模块交互介绍
  • C语言 ——— 浮点数类型 在 内存中 的 存储模式
  • socket 收发TCP/UDP
  • Nest.js 实战 (三):使用 Swagger 优雅地生成 API 文档
  • spark shell
  • 集群架构-web服务器(接入负载均衡+数据库+会话保持redis)--15454核心配置详解
  • # Redis 入门到精通(七)-- redis 删除策略
  • 10:00面试,10:08就出来了,问的问题有点变态。。。
  • html+canvas 实现签名功能-手机触摸
  • 前端组件化探索与实践:Vue自定义暂无数据组件的开发与应用
  • 《汇编语言 基于x86处理器》- 读书笔记 - Visual Studio 2019 配置 MASM环境
  • Air780E/Air780EP/Air780EQ/Air201模块遇到死机问题如何分析
  • 吴松洋院长 艺后整形集团专家组特约成员 全方位责任塑美
  • 前端经验:使用sheetjs导出CSV文本为excel
  • 【nnUNetv2进阶】十五、nnUNetv2 魔改网络-小试牛刀-引入ECA
  • centos(或openEuler系统)安装kafka集群
  • HarmonyOS根据官网写案列~ArkTs从简单地页面开始