Studio Switching to Perforce..need good introduction / ramp up


So my studio is making the switch form SVN / Git to Perforce for our next Unity project.
I need to get busy learning.

Where are some good resources for ramping up with perforce?

Any important issues using P4 with 3dsMax, Unity?


The unity integration is fair to middling. Your main source of pain is going to be .meta files - if people check in assets w/o metas you’re likely going to see assets that don’t work on some machines and do work on others. While the Unity integration tries to manage this for you it’s not flawless, and people will always check stuff in and out manually.

Learn how to write Perforce triggers and make one that rejects checkins of assets that don’t have matching meta files. That was the only thing that saved us from collective harakiri

Have strict naming conventions - PARTICULARLY for casing - because unity meta guids will diverge if different users have differently cased paths: Assets/A/B/C and Assets/a/b/c generate different guids for all of the folders, even though windows considers them the same path. You can configure perforce to treat A/B/C and a/b/c interchangeably, but it will still respect the casing users have on their own machines which can vary for all sorts of reasons.

Lightmapping is another constant irritation. When you rev lightmaps Unity tends to delete them rather than checking them out and updating them. Same for light probe data. So if you go that route, you’ll probably need to write a little helper for users so they don’t lose work.

Unity has a bad habit of silently checking out large numbers of files (usually because of guid or file casing conflicts as above). You probably want to configure perforce to ignore unchanged files. You also want to make sure that you DONT set auto-locking (ie, you-cant-check-out-because-i-checked-out) or people will be blocking each other left and right.

If you’re not familiar with the perforce api… well… it’s icky. You need platform specific binaries (even for the python bindings) and it’s very old school. Besides learning the commands you’ll need to learn p4’s odd ideas about how to answer your questions. It’s not exactly hard, it just takes a while and constantly violates the principle of least surprise


thanks again Theodox.

I have had experience with Maya / Alien Brain where artists were essentially opening assets form the AB interface
which would launch Maya, auto checkout and lock the asset file.
on closing the file from Maya it would check-in/unlock.
I assume P4 has similar capabilities?


No, but if p4v (the visual client) will use your native file associations so double-clicking a file in p4v will open the associated file. Auto-checkin on save is not a good idea in any case - you don’t want perforce to be full of temporary saves and you also want people to think about whether their stuff is ready for public view.

Lock exclusivity is optional in perforce. The usual workflow is:

  1. I check out
  2. I work
  3. I go to checkin
  4. If nobody else checked in the file while I had it , I 'm done
  5. If they have checked in while I had the file, I’ll be asked to merge. Unfortunately this almost never works with ma files and never works for mb, photoshop or others). I can stomp their changes, but I should not without talking to them.

I can voluntarily lock the file if I have it checked out, which will not allow conflicting checkins. However thats a pain if the other people want to do local testing or if they are Unity and Unity decides to check things out for its own mysterious $&!(&#^@ reasons. So I don’t like auto-lock in perforce, even though its an option. A lot depends on the professionalism of your team - one reason the Halo 3 marines look like crud is the contractor who stomped on all my skin shader / normal map work after working on his own for two weeks, something nobody noticed until after the depot had locked.

Checkin-checkout from inside Maya is is really easy; the trickier bit is that you have to choose between using the P4Python api – which is all done, but requires distributing platform specific binaries with your scripts – and writing a little wrapper that calls the p4 command directly from the shell, which is limited but doesn’t complicate your tools distribution. If you already have a good way to make sure users have the right dlls on their machines, add in p4.pyd and it’s just “‘edit’, cmds.file(q=True, sn=True))”.


Yeah, setup of Perforce integration in Maya can be fairly easy after you get over the initial hurdles of installing P4Python as Theodox mentioned. After that, you can pretty easily scale up and down according to how crazy you want to get with it. For the setup where I work, I made a shelf with buttons to run P4 commands on currently open files (so they can open a file, check it out, submit their changes, mark things for add or deletion etc.) and then also wrote a ScriptJob that initializes with Maya, and checks the current scene and any References and informs the user if it’s out of date, gives them the option of syncing and re-opening, then also gives them a little pop-up to warn them if it’s already checked out by someone. Just to avoid little mishaps that might come from people trying to merge files at the same time, I actually disabled the ability to check out already checked out ma files through our tools (figure if they really know what they’re doing and wanna risk it, they can just go to P4V.

So far, it’s been pretty stable and worked well with our artists seeming to like it. Most of all, it prevents mistakes and lost work from people not having things up to date. I’m thinking of trying update it and give the artists the option to also sync file textures, and it should be pretty easy now that the groundwork is laid out.

Here’s a good video I saw a while back that shows a good workflow created by P4Python in Maya that got me started when I was thinking about it. I’m thinking of doing my own video at some point soon too that goes in to our setup.

Hope that helps.


++ on version checking on scene open. I literally never had to un-screw an artist who’d inadvertenly worked on an out of date maya file for the whole of State of Decay :slight_smile:


Did you use a dialog, or a less intrusive warning?

I like the idea, I can just imagine having like 3 dialogs pop-up when I open a scene being kind of annoying, though I guess artists aren’t generally constantly opening scenes, and it may be worth the annoyance to ensure that it isn’t missed.


I have them as confirm dialogues and I was kind of worried it might be annoying to people, but I haven’t gotten any complaints. In my system, I skip that auto-checkout prompt on open in favor of just having a button to check it out as a conscious thing. So it’s 2 pop-ups max, and only if it happens to be out of date and currently checked out. But even so, I built in something to where artists can disable the script node if it gets too annoying or if it’s not working properly.


I brought up my previous AB/Maya experience, giving the impression that I’m dealing with Maya, but I’m not: the Studio is a 3DS Max studio.
hopefully it wont be any harder to communicate and script things.


Well hopefully this will all be easily done now that they have added python to 3DS. Haven’t tried it out yet, but if I work in a Max studio again, that’ll certainly be a welcome change if it works well. Guess if you aren’t using 2014 it’s still possible, albeit with a little more legwork needed.


If you’re just dipping into the Perforce Python API, there’s a post on my somewhat-neglected blog covering the basics. Might be useful. I posted that mainly as a lead-in to another post showing how to display Perforce operation progress/details to users. I should really make that second post. :slight_smile:



Have you guys looked at the P4 Graphical Tools that adds a menu to Maya and has options for checkout on open, checkin on save, updating to latest, checking file references revisions? Also has displays for file status and revision history.



setting up Max’s Python Implementation seems daunting.
Since P4 has a .NET api and we’re 3DS Max + Unity, and our Tools will be C# tools; it seems that .Net is a more logical choice than Python.
(oh how I miss python and Maya)

That said, you post makes a good list of “things I’ll need to know how to do with perforce”



I did find P4 Graphical Tools when I was doing some research on the whole thing, but I opted to just take the week or two to to write my own thing. Because of that, now I have an easy sort of toolset that I can (and have) easily add to other tools in our pipeline. Also an important thing that I wanted for our thing was to have it not be some separate thing they have to open up and check on file status and update, but something just integrated and works automatically


We are encountering checked out files being left as read only, preventing us form saving without manually changing the file properties in windows.
Does that sound familiar to anyone?


… maybe a tool that caches file locks at startup and doesn’t know files have been checked out during a session?


it seems to be a simple workflow issue. failing to get latest before checking things out.
skip that step and windows keeps them as read only, even when the checkout icon is clearly displayed in P4


hmm, that’s odd, even when checking out files that are out of date (which would of course not be recommended,) I’ve never had any issues with files still being locked. We’re using‘edit’ <FILENAME>) as the checkout operation with no flags or anything.


Yeah, same here. I’d suggest having a look at the server configuration. Might be an option that’s incorrectly set, etc.


Have I thanked everyone for their replies yet? thanks!
We hired a new Technical Director who has better perforce chops and things are being smoothed out.

My current concern is about tools exporting content to the right spot when everyone can potentially create their own work space configuration.

I like parallel source and production directories. My export tools ‘figure out’ where to place the exported asset by replacing the root level folder in the path string

but perforce lets a variety of work spaces be created all over the place,
and I need a reliable way to determine what is <source_art_path> and <production_art>.
based on either:
1.) make artists choose the right spot manullay
2.) somehow getting info from perforce
3.) enforcing a convention for work spaces on the art team.

3.) seems like the obvious approach. If so, can I script the creation of the workspace to force artists to adapt a common workspace configuration?
If so what scripting language? .bat with command lines? C# api? pyhton?

any experience you can share would help.