Search Unity

get unity cloud version number on game run time.

Discussion in 'Unity Build Automation' started by MatL, Sep 20, 2018.

  1. MatL

    MatL

    Joined:
    Jan 29, 2014
    Posts:
    43
    Hi, is possible to get the number of build on unity cloud when the game is running? something similar to Application.buildGUID, I want to print the number for for helping QA.
    Thanks.
     
  2. Kujo87

    Kujo87

    Joined:
    Sep 16, 2013
    Posts:
    168
    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using UnityEditor;
    4. using UnityEditor.Callbacks;
    5.  
    6. public class CloudBuildHelper : MonoBehaviour
    7. {
    8. #if UNITY_CLOUD_BUILD
    9.     public static void PreExport(UnityEngine.CloudBuild.BuildManifestObject manifest)
    10.     {
    11.         string build = manifest.GetValue("buildNumber", null);
    12.         PlayerSettings.bundleVersion = string.Format("{0}.{1}", PlayerSettings.bundleVersion, build);
    13.         PlayerSettings.iOS.buildNumber = build;
    14.        
    15.         int buildNo = 1;
    16.         int.TryParse(build, out buildNo);
    17.        
    18.         PlayerSettings.Android.bundleVersionCode = buildNo;
    19.     }
    20. #endif
    21. }
    22.  

    I use this. So I use major.minor.build for my versioning, so like I might be on V1.0 and then it'll append the build number to the end of it and yo ucan display it in game using Application.version;

    You need to add that function to the Pre-Export Method section in Advanced Options of your build config. Capture.PNG
     
    ollieblanks likes this.
  3. Kujo87

    Kujo87

    Joined:
    Sep 16, 2013
    Posts:
    168
    This also auto increments your Android bundle number as well, as I only upload release builds from Cloud, so I know my numbers have always increased.
     
  4. MatL

    MatL

    Joined:
    Jan 29, 2014
    Posts:
    43
    Thanks Kujo87 that's very helpful!
     
  5. herenow

    herenow

    Joined:
    Jan 11, 2017
    Posts:
    3
    Doesn't updating PlayerSettings.bundleVersion trigger a multi-day review process in the Apple app store? We use the PreExport too, but don't write to PlayerSettings.bundleVersion so that we get access to testflight builds in minutes instead of hours/days.