在項目開發過程中,往往會使用到SVN進行項目的版本備份管理,但是每次需要打開本地文件夾才能進行更新或提交SVN的內容。其實Unity提供相應的接口,可以實現一鍵更新或者提交SVN的內容,可免去很多繁瑣的操作,在做Editor工具的時候也可以用到,下面是代碼:
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using UnityEditor;
using UnityEngine;
using System;
public class SvnOperater : MonoBehaviour {
[MenuItem("SVN/Update")]
public static void SvnUpdate()
{
#if UNITY_STANDALONE_WIN || UNITY_EDITOR
Process.Start("TortoiseProc.exe", "/command:update /path:" + Application.dataPath + " /closeonend:0");
#endif
}
[MenuItem("SVN/Commit")]
public static void Commit()
{
#if UNITY_STANDALONE_WIN||UNITY_EDITOR
Process.Start("TortoiseProc.exe", "/command:commit /path:" + Application.dataPath + " /closeonend:0");
#endif
}
}