Unity3d Integrated TORTOISESVN

Source: Internet
Author: User
Tags tortoisesvn

Whether it is personal development or team development, develop good version management habits can greatly improve the development efficiency. Common version management software is typically used with SVN or git. Although 2 are used, they prefer SVN. Installing TORTOISESVN will allow you to integrate SVN management software into Windows Explorer directly. The right mouse button will have the SVN menu, which makes it easy to checkout items as well as commit and update.

When developing with Unity3d, the current mainstream code editor (IDE) chooses Virsual Studio (VS). As the universe's first powerful Ide,vs nature also has svn plugin--virsual svn. After installation, you can perform SVN operations in vs. As shown, if a project has been included in version management, there will be a tag in front of the file. Green indicates synchronization, yellow means no sync, and red indicates conflict. You can use the right key for SVN operation

But in the ointment is unity3d inside can't fast svn operation. It is usually back to the explorer and then submitted, not convenient enough. Looking at the SVN plugin on the Unity Asset store, it found that it was mostly too complex, or that some operations did not conform to the original operating habits. So for me to be very simple and efficient, I might as well write a gadget that is enough for me.

In "Unity Plug-in development-an example: simple SVN integration " , it has been explained that the method is Open a TortoiseProc.exe process with the Process.Start method and pass the parameters (click "TortoiseSVN action " to see all the parameters) to Tortoiseproc So that it executes the relevant command.

usingSystem;usingSystem.Diagnostics;usingSystem.IO;usingUnityeditor;usingUnityengine; Public classsvneditor:editorwindow{#regionSetupPrivate Const stringSvnkey ="Key_svnroot"; Private Const stringSvnname ="TortoiseProc.exe"; Private Static stringS_svnpath =Svnname; [MenuItem ("Svn/setup", priority =0)]     Public Static voidSetup () {GetWindow<SvnEditor>(); }    #endregion    #regionLog[MenuItem ("assets/svn/", priority =Ten)] [MenuItem ("Assets/svn/logall", priority = One)] [MenuItem ("svn/", priority =Ten)] [MenuItem ("Svn/logall", priority = One)]     Public Static voidSvnlogall () {svncmdproject (EMSVNCMD.LOG); } [MenuItem ("Assets/svn/log", priority =1)]     Public Static voidSvnlog () {svncmdselect (EmSVNCmd.Log);    }    #endregion    #regionUpdate[MenuItem ("assets/svn/update", priority =2)]     Public Static voidsvnupdate () {svncmdselect (emsvncmd.update); } [MenuItem ("Assets/svn/updateall", priority = A)] [MenuItem ("Svn/updateall", priority = A)]     Public Static voidSvnupdateall () {svncmdproject (emsvncmd.update); }    #endregion    #regionCommit[MenuItem ("Assets/svn/commitall", priority = -)] [MenuItem ("Svn/commitall", priority = -)]     Public Static voidSvncommitall () {svncmdproject (emsvncmd.commit); } [MenuItem ("Assets/svn/commit", priority =3)]     Public Static voidSvncommit () {svncmdselect (emsvncmd.commit); }    #endregion    #regionRevert[MenuItem ("Assets/svn/revert", priority =4)]     Public Static voidSvnrevert () {svncmdselect (Emsvncmd.revert); }    #endregion    #regionClearup[MenuItem ("Assets/svn/clearupall", priority =5)] [MenuItem ("Svn/clearupall", priority = the)]     Public Static voidSvnclearupall () {svncmdproject (Emsvncmd.clearup); }    #endregion    #regionCorePrivate Static voidsvncmdproject (emsvncmd cmd) {varPath =Application.datapath; varProject =directory.getparent (path); Processstart (CMD, project.    FullName); }    Private Static voidsvncmdselect (emsvncmd cmd) {var Select=Selection.activeobject; varPath = Assetdatabase.getassetpath (Select);    Processstart (cmd, path); }    Private Static voidProcessstart (emsvncmd cmd,stringpath) {#ifunity_standalone_win| | Unity_editor_winTry        {            varinfo =NewProcessStartInfo (s_svnpath) {Arguments=string. Format ("/command:{0}/path:{1}/closeonend:0", CMD. ToString ().            ToLower (), Path)};        Process.Start (info); }        Catch(Exception) {Setup (); }#endif    }    #endregion    Internal voidonenable () {S_svnpath=editorprefs.getstring (Svnkey); }    Internal voidOngui () {Editorguilayout.labelfield ("Set SVN");        Editorguilayout.space ();        Editorguilayout.beginhorizontal (); Editorguilayout.labelfield ("SVN program", Guilayout.width ( -)); Editorguilayout.selectablelabel (S_svnpath, Guilayout.width ( $)); if(Guilayout.button ("Select"))        {            varPath = Editorutility.openfilepanel ("Please select TortoiseProc.exe storage location","","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 enumemsvncmd {Log, Update, Commit, Revert, Clearup}}

Unity3d Integrated TORTOISESVN

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.