Perforce – Using Perforce with Unity3D
Creating and Initializing a New Perforce Depot
2. Setup new Depot
- Create new depot
- In your workspace, include the new depot, “include tree”.
- Create a windows explorer folder with the same name, in your perforce root folder.
- Add a first new file, like a text file. And commit this file to the depot.
- Add Unity/Unreal and continue with the other steps below
3. Add type map << Important!
To make sure Perforce understands how to to treat Unreal & Unity file types. We need to update the type map file. This is a global step, so only needed once for all perforce projects.
- Inside the Perforce client, go to any project folder, right click on it and select “Open Command Window Here”
- In the command window, enter: p4 typemap
- A text file should open. Update the file with the following list, then save and close the file.
!!! Restart the perforce client (and Unity/Unreal) and do a refresh in the perforce client.
4. Ignore files and folders
Add a text file in your perforce root called .p4ignore or .p4ignore.txt or whatever you like. Perforce uses the same setup as the git ignore files. So you can use the unity gitingore file found here: https://github.com/github/gitignore/blob/master/Unity.gitignore
Note: There can only be one accepted Ignore file name..
- Create a file in the root directory of the engine (eg: C:/Projects/Perforce/Unity) called .p4ignore
- Inside this file, define which file types to ignore. For example:
- The .swatches file from Maya.
- The Library folder from Unity.
- Local source file folders.
- Once this file is set up, open the command console (windows key + r then type in cmd) and type in: p4 set P4IGNORE = .p4ignore
- Now, Perforce should ignore the file types and folders defined in the text document.
- Next time an attempt to add this file is made, a warning should show up, and the files will not be added to your changelist.
- A # character at the beginning of a line denotes a comment. You can escape the # comment character with a backslash (\). This allows filenames beginning with # to be ignored.
- A ! character at the beginning of a line line excludes the file specification. These exclusions override rules defined above it in the P4IGNORE file, but may be overridden by later rules.
- A / (or \ on Windows) character at the beginning of a line causes the file specification to be considered relative to the P4IGNORE file. This is useful when the rule must apply to files at particular depots of the directory tree.
- A / (or \ on Windows) character at the end of a line causes the file specification to only match directories, and not files of the same name.
- The * wildcard matches substrings. Like the Helix server wildcard equivalent, it does not match path separators; however, if it is not used as part of a path, the directory scanning nature of the rule may make it appear to perform like the Perforce “…” wildcard.
- The ** wildcard matches substrings including path separators. It is equivalent to the Helix server “…” wildcard, which is not permitted.
5. Deleting Depots
If deleting depots is declined or failed. Make sure all workspaces, streams and files linked to the depot are deleted/obliterated. If it still fails, use the following command to force it: p4 depot -f -d DepotName