Does anyone know anyway to access the version control settings in the editor?
I’d like to access P4V specifically in editor scripts to automatically check out files that are procedurally being generated/edited through code.
I found a c# implementation here, which runs command line instructions perfectly fine on windows and it’s exactly what i want, however - it doesn’t work on OSX. Also it requires the user to re-enter their credentials, even though they are logged into P4V through Unity version control settings.
Is there anyway i can access the version control settings to grab the credentials? Does anyone know of any way to access the perforce or version control API in unity? Or at least a way to use the perforce API without using the command line tool.
This works for me on OSX for getting P4 information from Editor script:
string p4ServerAndPort = EditorUserSettings.GetConfigValue( "vcPerforceServer" );
string p4User = EditorUserSettings.GetConfigValue( "vcPerforceUsername" );
string p4Workspace = EditorUserSettings.GetConfigValue( "vcPerforceWorkspace" );
You could us different UnityEditor.VersionControl functions to do P4 operations. Don’t forget task.Wait(); before using anything form the UnityEditor.VersionControl.Task returned.
Revert does not seem to work via UnityEditor.VersionControl, but a command line like
string command = "-c \"/usr/local/bin/p4 -p '";
command += p4ServerAndPort + "' -u '";
command += p4User + "' -c '";
command += p4Workspace + "' revert '";
command += file + "'\"";
(that you can run with System.Diagnostics.Process setting proc.StartInfo.FileName = “/bin/bash” works fine (will need to run Command on Win instead of bash, I guess).