Having Subversion (SVN) control is key in any project, and in Unity it was previously a pain to setup and tough to work with. Now with Unity’s release of 3.5, they’ve simplified the process and made it available to all users! The process is as follows:
Go to the Editor Settings panel Edit > Project Settings > Editor
This should show the Editor Settings in the Inspector window.
The Version Control mode will default to disabled. Turn that to “Meta Files”. Doing this will allow your project to be better used with SVN by creating meta files that go along with all of the assets in your project.
Right now in this demo project I have one asset of a ship.
When you view this project in Finder (Mac) or Explorer (Windows) you’ll see 2 files associated with Ship: Ship.png and Ship.png.meta.
Unity uses that meta file to keep track of the data and settings associated with that asset. So all files in your Assets folder will have a .meta file along with it, including folders.
Now that you have Meta Files enabled, close the Unity project. Go to Finder and delete the Library folder completely. Then Add and Commit both the “Assets” and “ProjectSettings” folders to your SVN repository. And that’s it! Now when you relaunch your Unity project, it will load in all the meta files and automatically restore the Library folder and files that are used for the runtime. There’s no need to Add or Commit anything that’s in the Library folder, just leave that there as is. You will only need to worry about the Assets and ProjectSettings folders for committing updates and new files. Keep in mind that if you want to move or rename a file, you will need to move its .meta counterpart. If you’re moving things around in the Unity Project view Unity will do that for you.
Since you’ll never be needing to add or commit any changes to any files in the Library folder, you might find it nice to have SVN setup to ignore those files. Here’s an article that will walk you through the process.
You’ve now got Unity ready for SVN management. There is one extra step that you could do if you have the Pro version of Unity, and I recommend this step. For one of our projects, we had trouble with 2 or more people being in the same Scene at the same time, or editing the same Prefab. The reason for this is because Unity defaults saving Scenes and Prefabs in a binary data form for a quicker Unity runtime. But for more flexibility with SVN, changing this to a text-based file format will save you headache later on.
To enable this feature open back up the Editor Settings and under the “Asset Serialization” field, change the Mode to “Force Text”. That will force all assets, whether they’re Scenes or Prefabs, to be saved in a text format for easier merging by SVN.
If you have any troubles with this setup, also read the Unity Reference about External Version Control here.
And if you really want to know what is going on when assets are saved in a text format, this is a good place to start.
Thanks for reading and I hope that this made someone else’s Unity experience a happier place.