Using External Version Control Systems with Unity
Unity offers an Asset Server add-on product for easy integrated versioning of your projects. If you for some reason are not able use the Unity Asset Server, it is possible to store your project in any other version control system, such as Subversion, Perforce or Bazaar, although this requires some manual initial setup of your project and moving and renaming of assets has to be performed using your version control client and not inside Unity.
External Version Control is a Unity Pro feature.
Before checking your project in, you have to tell Unity to modify the project structure slightly to make it compatible with storing assets in an external version control system. This is done by selecting in the application menu and enabling External Version Control support by clicking the Enable button. This will create a text file for every asset in the Assets directory containing the necessary bookkeeping information required by Unity. The files will have a .meta file extension with the first part being the full file name of the asset it is associated with. When moving or renaming assets in the version control system, make sure you also move or rename the .meta file accordingly.
When checking the project into a version control system, you should at least add the Assets directory to the system. If you want to track project and build settings as well you can also add Library/*.asset, and Library/BuildPlayer.prefs. Do not add any other files or directories located inside the Library directory. When creating new assets, make sure both the asset itself and the associated .meta file is added to version control.
Example: Creating a new project and importing it to a Subversion repository.
First, let's assume that we have a subversion repository at svn://my.svn.server.com/ and want to create a project at svn://my.svn.server.com/MyUnityProject.
Then follow these steps to create the initial import in the system:
- Create a new project inside Unity and call it
InitialUnityProject. You can add any initial assets here or add them later on. - Enable Meta files in
- Quit Unity
- Delete the contents of the
Librarydirectory inside your project folder. Don't delete the directory itself. - Import the project folder into Subversion. If you are using the command line client, this is done like this from the directory where your initial project is located:
svn import -m"Initial project import" InitialUnityProject svn://my.svn.server.com/MyUnityProject
If successful, the project should now be imported into subversion and you can delete theInitialUnityProjectdirectory if you wish. - Check out the project back from subversion
svn co svn://my.svn.server.com/MyUnityProject - Optional: Set up an ignore filter for the unversioned files inside the
Librarydirectory:svn propedit svn:ignore MyUnityProject/Library
Subversion will open a text editor. Add the following file names to the file and save it.AssetServerCacheV3FailedAssetImports.txtScriptAssembliesScriptMapperTempassetDatabase3cacheguidmappermetadataunity default resourcesunity editor resources
- Open the checked out project with Unity by launching it while holding down the Option or the left Alt key. Opening the project will recreate the missing files deleted from the
Librarydirectory in step 4 above. - Add the project settings to the subversion repository:
svn add MyUnityProject/Library/*.asset MyUnityProject/Library/BuildPlayer.prefs - Finally commit the changes. The project should now be set up and ready:
svn ci -m"Finishing project import" MyUnityProject
