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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Is it possible to extract the current cs number through code?

Discussion in 'Unity Version Control' started by Jono00, Jan 31, 2023.

  1. Jono00

    Jono00

    Joined:
    Jun 27, 2014
    Posts:
    5
    Hey,
    I want to make tracking versions of my game easier by appending the cs used at build time to the version number
    For example if my current build version is 1.1.0, and my current cs number is 1234, then the final build version will be 1.1.0.1234

    Is this possible?
    Thanks.
     
  2. carlosalba1985

    carlosalba1985

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    863
  3. Jono00

    Jono00

    Joined:
    Jun 27, 2014
    Posts:
    5
    Hey Carlos,
    Thanks for the response. This isn't exactly what I was going for.
    What I want to do is to be able to change the build version (the one used in the Player Settings window) and append to it the current CS version.

    My game displays its current build version in the main menu, so it would be very useful for use to track the exact CS used in a build in a glance.
    Thanks again!
     
  4. carlosalba1985

    carlosalba1985

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    863
    From the Plastic SCM point of view, you can easily get the changeset id. You can check the id in the branch explorer view or via "cm find changeset".

    Can you let me know how are you defining the build version? I guess this is out of the Plastic SCM plugin scope but some settings in the editor.

    Regards,
    Carlos.
     
  5. Jono00

    Jono00

    Joined:
    Jun 27, 2014
    Posts:
    5
    I'm doing something similar to what's shown in this video (skip to 4:44)


    What I want to achieve is that, instead of displaying [version number] - [current date], it would display [version number] - [current cs number].

    It may well be something out of the plugin scope, so apologies if that is the case and I posted in the wrong forum

    Thanks.
     
  6. carlosalba1985

    carlosalba1985

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    863
    Hi,

    You can use CmdRunner to run Plastic SCM operations via the command line: https://docs.plasticscm.com/cmdrunner/plastic-scm-version-control-cmdrunner-guide#Introduction
    CmdRunner is an automation layer built on top of the command line. It's built on .NET using C#

    If you run the following command in the root of your workspace, you can get the list of changesets and use the latest one:
    Code (Boo):
    1. cm find changeset --format={id}
    In general, via "cm find", you can query your repository: changesets, branches... and use this query output in your [version number] variable.
    https://docs.plasticscm.com/cmfind/plastic-scm-version-control-query-system-guide#Changesets

    Regards,
    Carlos.
     
    shai_unity622 likes this.