Search Unity

Where can I set the version number?

Discussion in 'Unity Cloud Diagnostics' started by Hyp-X, Aug 1, 2016.

  1. Hyp-X

    Hyp-X

    Joined:
    Jun 24, 2015
    Posts:
    438
    At the performance report I see the "Affected Version" is 1.0
    Where can I set this version number?
    (Unity 5.4 target platform: Windows / x64)
     
  2. Ryan-Unity

    Ryan-Unity

    Joined:
    Mar 23, 2016
    Posts:
    1,993
    Hi Hyp-X,

    The Affected Version number is grabbed from the Player Settings in Unity. To set that version, go to Edit-->Project Settings-->Player, then hit the tab with the icon of a phone to switch over to iOS settings. Underneath Identification you will see Version tucked between Bundle Identifier and Build.

    Screen Shot 2016-08-01 at 10.48.41 AM.png

    Setting Version will change the version of your app the next time you build or run your project. I hope this answers your question and let us know if you have any other comments or concerns.
     
    perevezentsev likes this.
  3. Hyp-X

    Hyp-X

    Joined:
    Jun 24, 2015
    Posts:
    438
    Thanks.

    I didn't want to download and install iOS support, just to set a variable, but I found I can set this manually in ProjectSettings.asset as "bundleVersion" or from script as PlayerSettings.bundleVersion

    This code should help most people (BuildInfo.buildNumber needs to be substituted for something that you have in your build system)

    Code (CSharp):
    1. using UnityEditor;
    2. using UnityEditor.Callbacks;
    3.  
    4. public static class VersionHelper
    5. {
    6.     [PostProcessScene(10)]
    7.     static void SetBuildVersion()
    8.     {
    9.         if (EditorApplication.isPlayingOrWillChangePlaymode)
    10.             PlayerSettings.bundleVersion = "Editor (" + System.Environment.MachineName +")";
    11.         else
    12.             PlayerSettings.bundleVersion = "Build " + BuildInfo.buildNumber + " (" + System.Environment.MachineName + ")";
    13.     }
    14. }
    15.  
     
    malkere and Ryan-Unity like this.
  4. blueteak

    blueteak

    Joined:
    Feb 19, 2013
    Posts:
    140
    Made a little editor window that lets you set the version number using the same PlayerSettings.bundleVersion

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3.  
    4. public class VersionHelper : EditorWindow
    5. {
    6.     string versionNum;
    7.     string lastVersion;
    8.     bool changed;
    9.     [MenuItem("Window/Version Helper")]
    10.     public static void ShowWindow()
    11.     {
    12.         EditorWindow.GetWindow(typeof(VersionHelper));
    13.     }
    14.  
    15.     void OnGUI()
    16.     {
    17.         if (!changed)
    18.         {
    19.             versionNum = PlayerSettings.bundleVersion;
    20.             lastVersion = versionNum;
    21.         }
    22.         EditorGUIUtility.labelWidth = 80;
    23.         versionNum = EditorGUILayout.TextField("Version", versionNum);
    24.         if(lastVersion != versionNum)
    25.         {
    26.             changed = true;
    27.         }
    28.         if (changed)
    29.         {
    30.             if (GUILayout.Button("Set Version"))
    31.             {
    32.                 PlayerSettings.bundleVersion = versionNum;
    33.                 changed = false;
    34.             }
    35.         }
    36.     }
    37. }
    38.  
     
  5. Tuni

    Tuni

    Joined:
    May 24, 2013
    Posts:
    74
    Maybe you should change (or let the team in charge of the player settings know) that the version number should be accessible from other platforms too? Telling a standalone only dev to download and install support for a mobile platform to change the version number of your game sounds wrong.
     
  6. Arthur-LVGameDev

    Arthur-LVGameDev

    Joined:
    Mar 14, 2016
    Posts:
    228
    This is still an issue, and I concur 100%! Or at least document how to change it via code, which is what we wanted to be able to do anyways!
     
  7. Ryan-Unity

    Ryan-Unity

    Joined:
    Mar 23, 2016
    Posts:
    1,993
    Hi @Tuni and @ADanto6840! You're right that this is still an issue and needs to be better. We're hoping to add a universal version that can be used by the entire Editor without requiring any specific platform in the future.
     
  8. TitanUnity

    TitanUnity

    Joined:
    May 15, 2014
    Posts:
    180
    Does Unity have a recommended practice for how to better control version reporting in Game Performance Tools now that we no longer call CrashReporting.Init() in Unity 5.5? Here's a specific example where this is problematic:

    1. Our team starts working on version 1.5.0 of our game.
    2. We set the Application.version value to 1.5.0 in the Build Settings.
    3. We begin development, distributing multiple test builds to our network of testers over the course of a few weeks.

    Previously we had been using an internal buildNumber property that we append to the Application.version value when initializing CrashReporting. We appended a suffix like this "1.5.0b1", "1.5.0b2", "1.5.0b3", "1.5.0b4" so that we could get versioned error reports to appear in Game Performance Reporting that we could filter on. Since iOS doesn't allow you to upload builds with a format like this, how do you recommend we move forward to get clear error reporting per version during testing? We don't want to change our versioning format, but currently we have no way to get errors broken down per test build. We preferred the old way where the developer was in control of the version passed into the system.
     
  9. Ryan-Unity

    Ryan-Unity

    Joined:
    Mar 23, 2016
    Posts:
    1,993
    Hi @TitanUnity! I tried using a similar naming format ("1.5b1") for one of my test projects and was able to build just fine to my iPad mini running on iOS 10.2.1. The crash reports from this build can be filtered by that version, as well. I'm not sure what format restrictions you're seeing on your end. Can you point to anywhere online that mentions this or screenshots of errors that you're seeing in Xcode when you try this format?

    If for some reason you can't using letters in your version format, perhaps you could try underscores? I tried that as well with iOS and didn't have issues there either. Maybe give something like "1.5.0_1" a try. I hope that helps to answer your question.
     
    metanautvr likes this.
  10. MrLucid72

    MrLucid72

    Joined:
    Jan 12, 2016
    Posts:
    988
    That would rock!! It's way more complicated than I thought it would be lol
     
  11. pesahov

    pesahov

    Joined:
    May 24, 2017
    Posts:
    12
    Any updates on this feature?
     
  12. Infrid

    Infrid

    Joined:
    Jan 14, 2012
    Posts:
    67
    +1 for me - I'm currently doing a custom script with auto version date - it's less than desirable.
     
  13. MrLucid72

    MrLucid72

    Joined:
    Jan 12, 2016
    Posts:
    988
    How is this not a feature, yet D:
     
    DMorock, ghellee, kloot and 1 other person like this.
  14. Melon24

    Melon24

    Joined:
    May 14, 2018
    Posts:
    1
    do u know how to throw user to play store for update when new version release
     
  15. Mgravitus

    Mgravitus

    Joined:
    Oct 8, 2015
    Posts:
    13
    @Ryanc_unity any update on this feature, again having to change settings in a different platform not ideal when auto retrieving version number.
     
  16. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    332
    I think you wanted @ryanc-unity
     
  17. joshenes

    joshenes

    Joined:
    Apr 18, 2014
    Posts:
    48
    You don't need a script or to add any iOS support.
    - Edit > Project Settings > Player.
    - Under "Other Settings" there is a "Mac App Store Options" section.
    - Change the field labeled "Version*".
     
    clickytwisty likes this.
  18. clickytwisty

    clickytwisty

    Joined:
    Feb 12, 2018
    Posts:
    2
    In 2019.2, the fields are labeled better.

    - Edit > Project Settings > Player
    - Android tab > Other Settings > Identification section
    - Change the field "Bundle Version Code"
     
  19. unity_BowO8jUnsRg3Lw

    unity_BowO8jUnsRg3Lw

    Joined:
    Mar 19, 2020
    Posts:
    16
    my hero and savior
     
  20. Arthur-LVGameDev

    Arthur-LVGameDev

    Joined:
    Mar 14, 2016
    Posts:
    228
    For what it's worth, we gave up on using the built-in "version" stuff for this & finally resorted to using a "TextAsset" that gets created during our build process.

    How it works:
    During the build process [at the very beginning], we instantiate a small "BuildVersionInfo" (derived from ScriptableObject) and then we serialize it to JSON and save it as a ".asset" file in the Resources dir. The game loads the TextAsset at startup and reads the version data from the text asset.

    Initially we used some assembly trickery to identify build date, but after some time we ended up needing a *bit* more version data/meta-data (ie 'branch'/built 'intent' and the SHA1 from source control).

    Overall, our solution works just fine -- and means we aren't reliant on Unity functionality potentially changing in the future for our "public versioning" purposes. It did take a few hours to make sure it worked correctly with the "build sequencing" as far as assets/asset database goes, but it worked, and that's all we wanted so we could get back to gameplay code.
     
    mertkalak likes this.
  21. kloot

    kloot

    Joined:
    Mar 14, 2018
    Posts:
    78
    Also giving up on this and making a custom implementation. All I wanted was a way to update the platform independent "version" available under Project Settings->Player->Version... Unity allows us to update it manually in the editor, but not through script (for some undisclosed reason)...
     
  22. Wappenull

    Wappenull

    Joined:
    Oct 29, 2013
    Posts:
    51
    For now I could confirm that
    PlayerSettings.bundleVersion = "1.2.0";

    Does change "Project Settings->Player->Version" just fine.
    upload_2021-9-13_11-32-8.png
     
  23. kloot

    kloot

    Joined:
    Mar 14, 2018
    Posts:
    78
    Yes, the (potential) problem is that setting that value also updates "Application bundle version shared between iOS & Android platforms.".

    The docs doesn't go into what this actually means tho...
     
  24. Rachan

    Rachan

    Joined:
    Dec 3, 2012
    Posts:
    776
    this version number can set by code?
     
    kloot likes this.