Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Default117 · Jun 02, 2013 at 03:30 AM · perforce

Perforce API access in editor

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by MikhailMukin · Jul 03, 2014 at 07:31 PM

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).

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

15 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

P4Connect plugin inactive 1 Answer

ScriptableObject Asset Files Invalid Header, Perforce Revision 1 Answer

Perforce Save Project checks out random prefabs 0 Answers

Edit->Project Settings->Editor Perforce Greyed Out 1 Answer

Asset serialisation (Text only) Perforce and Corruption 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges