When working with others or even individually on a large project, it is critical that you have some type of versioning control. Over the years I have used many types of versioning depending on the project and the scope; Dropbox, Google Drive, GitHub, GitLab, local versioning using subversion, and now I am shifting to Perforce to use with my students on Unity 3D, VR, and Babylon.JS WebVR projects.
In this example, I have focused on configuring the system for Unity, but it was very easy to version my Babylon.JS folder as a Depot.
tl;dr – I have added a video that walks through this process at the bottom.
Versioning Definition: As changes are made, each version of the changes are stored so that if there is a problem, you can return to an earlier version.
Step 1: Server
Download P4V and P4D (Helix Server) for your installation. I selected the Linux x64.
While you can install Perforce P4D (the Helix server) locally for personal versioning, my current projects include many of my students, thus I needed a remote server. For this installation I used Amazon Web Services, creating an EC2 micro instance and set the storage space at 100GB (probably more than I need initially, but with students, storage space tends to get gobbled up). After launching the instance and setting a permanent IP address, I followed this YouTube tutorial. It was fast and easy. Just follow the steps. One correction in the video: The author downloaded P4D for the install. You will probably be downloading the helix server.tgz file, which will need to be decompressed using tar. On your command line type:
tar -xvf helix-core-server.tgz
This will extract the P4D file. You can then continue the video instructions.
Note: Be sure to review the Perforce license options for your project.
2. Perforce Viewer (P4V)
Once you have your server configured, you are ready to set up your local machine. Run the P4V and install it to your preferred location.
Once it is installed, you will need to connect to the server that you just configured.
Enter your URL or IP address and add :1666 to the server setting. :1666 is the port used by Perforce for sending and receiving data.
For User, click the New button and fill in the information.
Workspace is optional. If you will be using the server for multiple personal projects with multiple people, I recommend requiring each user to put their user name as a part of the workspace name.
Once you have everything filled in, click the OK button and P4V will launch showing the projects. You can also set up a personal server (the second tab) on your local computer to handle personal versioning (which is beyond the scope of this tutorial).
A few definitions for on the tools for working with a repository (this applies to git as well):
Depot – Perforce stores files in Depots. It is similar to folders on your hard drive. If a file is currently in a depot, then it is being versioned. The Depot is on the server and is separate from your workspace.
Workspace – Your local work files. Clicking on the Workspace tab will show your current working folder on your computer.
Refresh – Downloads the latest files that you have not checked out (files that you are not editing.
Get Latest – Downloads the latest version of the repository/depot to your local computer. The files are downloaded as read-only, thus this is for viewing or testing others work, not for making changes.
Submit – Uploads the checked-out files that have changed from your local computer to the repository/depot.
Checkout – Downloads the current version (or past versions) of the depot for editing. If someone else has checked-out the same file, if you submit that file, you will have a versioning conflict that will have to be resolved.
Revert – Switches back to an earlier version (generally, only the files that you have opened).
Diff – Compares to files and shows the differences. Very useful when you are trying to resolve a file conflict!
Revgraph – A graphic representation of revisions made to the project.
Init – Configures a personal server for your use.
Clone – Creates a copy of a project, allowing you to create a fork or conduct an experiment to see if going a different direction with the project would work.
Fetch – Used with Init or Clone; copies the files from your personal server to your local computer.
Push – Used with Init or Clone; copies files from your local computer to your personal server.
3. Unity
Now that you are logged in to your Perforce server, we are ready to configure Unity. Leave P4V running, and launch Unity if haven’t already. In the project that you want to save to a Depot, click Edit on the Menu, then Project Settings
This will open the Project Settings Dialog. Select Editor on the left. On the right under Provisioning, select Perforce from the drop-down menu.
With Perforce selected, you will be able to enter your Username, Password, Workspace, and IP/URL (remember to include :1666 for the Perforce port).
When you have filled in those text fields, click on the Connect button. If you still have P4V open, you should be connected to the server. Unity may notify you that the scene needs to be reloaded to continue.
Take a moment to review the different icons used by Unity to show the status of your assets and if they are in sync with the Depot on the server.
When you are finished, close the settings dialog box. In your Project tab, you should now see that the scene has a Local overlay. Right-click on scene, select Version Control > Mark Add, then repeat the process and Submit
You will be asked to complete the Version Control Changeset. Once you have entered a description of the changes that you have made, click the Submit button. Note that click Save does not upload the changes to the server, only Submit will upload the updates.
Once you have submitted the changes, you can view P4V and see that your updates have been added to the repository. Congratulations! You did it!
4. Best Practices
When working with a team, there are a few best practices that will help keep harmony:
a) Everyone should be using the same version of Unity. Do not upgrade unless the entire team upgrades.
b) Only Checkout files that you are editing. If you are working on scripting, only checkout those scripts.
c) Seriously, only Checkout files you are editing. A Get Latest will make sure you are up-to-date.
d) Never do a full Revert without notifying the rest of the team.
I have recorded a quick walkthrough of the process of configuring P4V and Unity.
© 2019 – Brian Burton, Ed.D. My VR Professor.com