Version control integration (Team license only)

Unity supports version control integration with Perforce.

To start working with Perforce in Unity, do the following:

  1. Setup or sync a workspace on your computer using a standard Perforce client such as perforce p4v. Refer to perforce documentation to learn how to do this.
  2. Copy an existing project into the workspace or start Unity and create a new project in the workspace.
  3. Open the project and go to the Edit->Project Settings->Editor menu.
  4. Choose your Mode according to the version control system that you chose.
  5. Fill out your version control settings, such as username / password / server / workspace.
  6. Keep Automatic add checked if you want your files to be automatically added to version control when they're added to the project (or the folder on disk). Otherwise you will have to add new files manually.
  7. Offline mode checkbox should be left off. Only use this if you know how to work offline in Perforce without a Sandbox.
  8. You should select Force Text as Asset Serialization Mode, so you can compare and merge files visually.
  9. Click connect and verify that "Connected" is displayed above the connect button after a short while.
  10. Use your standard perforce client (p4v) to make sure that all files in the Assets and ProjectSettings folders (including files ending with .meta) are added to Perforce.

At this point you should be able to do most of the important version control operations directly on the assets in the project view, instead of going through the version control client.

You should also be able to see the status that each asset has. An asset can be:

You can overview the files in your changelist from the Version Control Window (Window->Version Control). It is shown here docked next to Inspector in the editor:

By right clicking assets or changelists in this window you perform operations on them. To move assets between changelists just drag the assets from one changelist to the header of the target changelist.

Things to note:

Icons

The following icons are displayed in Unity editor to visualize version control status for files/assets:

File added locally
File added to version control by another user
File is checked out by you 
File is checked out by another user
There has been a conflict merging this file. Needs to be resolved
File has been deleted by you
File has been deleted by another user
File is not yet under version control
File is locked by you
File is locked by another user
Another user has checked in a new version of this file. Use "Apply Incoming Changes" to get latest version

Automatic revert of unchanged files on submit

When working with assets, Unity automatically checks out both the asset file as well as the associated .meta file. In most situations however, the .meta file is not modified, which might cause some extra work e.g. when merging branches at a later point. It's possible to configure Perforce to revert unchanged files on submit, which is done in P4V by selecting Connection->Edit Current Workspace..., viewing the Advanced tab and setting the value of On submit to Revert unchanged files:

Offline Mode

Unity supports working in offline mode, e.g. to continue working without a network connection to your version control repository. Please refer to Perforce documentation for further information on working in offline mode for Perforce.

Troubleshooting

If Unity for some reason cannot commit your changes to Perforce, e.g. if server is down, license issues etc., your changes will be stored in a separate changeset. If the console doesn't list any info about the issue you can use the P4V client for Perforce to submit this changeset to see the exact error message.

Working with the Asset Server

For work with the Asset Server (Unity's internal Version Control System) refer to the Asset Server documentation.

Working with other version control systems

In order to work with a version control system unsupported by Unity, select MetaData as the Mode for Version Control in the Editor Settings. This allows you to manage the source assets and metadata for those assets with a version control system of your choice. For more on this, see the documentation for External Version Control Systems

Page last updated: 2013-07-04