Skip to content

Instantly share code, notes, and snippets.

@colinsenner
Created November 10, 2020 00:21
Show Gist options
  • Save colinsenner/79899d1613079ca2af66a5f5b74e2177 to your computer and use it in GitHub Desktop.
Save colinsenner/79899d1613079ca2af66a5f5b74e2177 to your computer and use it in GitHub Desktop.
Unity Cloud Build AutoIncrement
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
// https://bigcheeseapp.com/2019/04/25/automatically-set-ios-build-number-and-android-version-code-in-unity-cloud-build/
public class AutoIncrementVersion
{
#if UNITY_CLOUD_BUILD
public static void PreExport(UnityEngine.CloudBuild.BuildManifestObject manifest)
{
string buildNum = "unknown";
Debug.LogFormat($"PreExport:: PlayerSettings.WebGL.template = '{PlayerSettings.WebGL.template}'");
manifest.TryGetValue<string>("buildNumber", out buildNum);
Debug.LogFormat($"AutoIncrementVersion.PreExport() called, build number is {buildNum}");
string versionString = $"{Application.version}.{buildNum}";
Debug.LogFormat($"PlayerSettings.bundleVersion set to {versionString}");
PlayerSettings.bundleVersion = versionString;
}
#endif
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment