Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Get Plastic GUID of Asset

Discussion in 'Unity Version Control' started by alchemist_wurzelpurzel, Jan 6, 2023.

  1. alchemist_wurzelpurzel

    alchemist_wurzelpurzel

    Joined:
    Sep 4, 2018
    Posts:
    43
    Hello people!

    We are using Plastic SCM in our team and it's great. Every now and then there is a need to have an admin unlock an asset that is checked out by someone else and cannot be unlocked easily, e.g. when someone checks it out in the office and then works from home. I am aware that this reverts all changes made to the asset.

    To unlock an asset that was checked out by someone else, I have been using the command line like so:
    1. Get the list of all checked out assets and their GUIDs with
    Code (CSharp):
    1. cm listlocks --server=OURCOMPANYNAME@cloud
    2. Find the asset and its guid
    3. Unlock the asset via
    Code (CSharp):
    1. cm lock unlock OURCOMPANYNAME@cloud <GUID>
    Now I am lazy and doing this every time to unlock an asset is tedious. So I wanted to create a Menu Item in Unity that just unlocks an asset when clicking on it. Easy enough, just start a cmd.exe process and pass the above code from step 3 with the asset guid as an argument, right? Wrong!

    Apparently Unity and Plastic GUIDS are different, so I cannot just use the GUID provided by Unity to unlock the asset. Is there a way to get the Plastic GUID of the asset? I couldn't find anything in the Provider API and now I am lost.

    Thanks!

    EDIT: By Provider API I meant this: https://docs.unity3d.com/ScriptReference/VersionControl.Provider.html
     
    Last edited: Jan 12, 2023
  2. Rafafor_unity

    Rafafor_unity

    Unity Technologies

    Joined:
    Aug 12, 2021
    Posts:
    30
  3. alchemist_wurzelpurzel

    alchemist_wurzelpurzel

    Joined:
    Sep 4, 2018
    Posts:
    43
    Hi @Rafafor_unity and thank you for your response!

    I was not aware of the CmdRunner API and it seems very convenient!
    Unfortunately, when trying the example with the cm version command as described on the link you gave me, the process result fails with "cannot find file".

    We are using Unity 2021.3.9f1 and the Version Control Package 1.17.7.
    This is my code:
    Code (CSharp):
    1. var result = CmdRunner.ExecuteCommandWithResult(new string[] { "cm version" }, Environment.CurrentDirectory);
    The CmdRunner.ExecuteCommandWithStringResult function does not exist for me so I used ExecuteCommandWithResult and tried to access the ProcessResult.Output but the whole thing failed with said error.

    Then again, even if I could make this work, I would still have to somehow get the Plastic Guid of the Asset that I want to unlock since the Unity provided Guid does not work. I guess I could search for the Asset Name in the output of cm listlocks --server=OURCOMPANYNAME@cloud and then find the Guid with that unless you know a better way?
     
  4. carlosalba1985

    carlosalba1985

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    842
    CmdRunner is an automation layer built on top of the command line. But there is no problem is you prefer to directly run the "cm" commands.

    Plastic guids are not related to any Unity guids.
    In order to get the guid to unlock the item, you can use "cm listlocks" and grep the output for the specific item path you want to unlock.