SVN as version control in Unity and WiseSVN package

If you trying to develop any game in Unity or even if you are trying to experiment with Unity I suggest using some kind of version control system. Even if you are developing something alone. It will bring a lot of benefits:

  • You will have a backup of your code.
  • You will see a list of changes before you commit changes. This can help you see unwanted changes. Once I spent a few hours because I accidentally press a minus key.
  • It will allow you to go back in time and get the version day/week/month ago. It is very helpful because sometimes you do change that broke something but you didn’t see it immediately. And later it would be very hard to find what change broke your code. But if you commit often, usually it will take from minutes to an hour to find the change that broke the functionality.
  • It is much easier to experiment with your code. Just make sure you commit everything before you start experimenting. If your experiment is successful then commit new changes. Otherwise just roll everything back. It happened to me very often. I had a great (I think) idea and then I started refactoring. And then somewhere in the middle, I found that it is a bad idea. It takes a lot of time to revert everything back and very often I forgot something. VCS makes it extremely easy.
  • It is very easy to go back to the old code. For example, you may refactor code and everything looks good for some time. Then you may realize that you didn’t take into account some cases that the old code did. In this case, you can check how the old version works.
  • It is very helpful to review your changes just before commit. It helps to find some experiments or unfinished code. Sometimes it helps you to find nonoptimal code.

And list above is what came to my mind immediately. There are way more benefits. You definitely should use it if your code is more than 100 lines of code. Every professional developer is using some kind of version control system.

One of the most popular version control systems is GIT. It is a quite powerful VCS, but it is quite complex to use and to set up. We switched to GIT at my work about 20 months ago and we still have some issues periodically because it is not easy to understand and requires a lot of learning from developers.

It is why I suggest using SVN for smaller teams. SVN is free and easy to set up, you just install TortoiseSVN and that’s it. And most importantly - it is easy to learn. You create the local repository and check it out. Then do some changes and commit them. And periodically backup your repository.

At my work, we used SVN for almost 10 years and we had really big repositories. Our main source code repository was close to 30 gigabytes when was checked out to the developer’s computer. And our test repository was even bigger and is more than 70 gigabytes. We never had any issues with SVN itself. We switched to GIT because we want to have more flexibility with branches and merges.

But Unity does not support SVN natively. Here is a list of things you need to do:

  • Go to Edit -> Project Settings -> Version Control, and in the inspector change “Mode” to “Visible Meta Files”.
  • Go to Edit -> Project Settings -> Version Editor, find “Asset Serialization” section, and change “Mode” to “Force Text”.

After that, you can add your project to SVN and do typical things you do with SVN. But the experience will be rather bad. If you add any file in Unity, then you will have to add it manually in Tortoise SVN. The same with deleted files. But the worst thing is renaming. In this case from SVN’s point of view, it looks like one file was removed from SVN and a new unversioned file was added. An even worse situation happened with directories.

And then I found the WiseSVN package and it changed the way I interact with SVN in Unity. Basically, it does all dirty work and then I got to TortoiseSVN and just commit changes. It works great and I highly recommend this package if you are using SVN.

I hope it helps someone.

Comments

Post comment