public void OnPreprocessBuild(BuildReport report) { if (report.summary.platform == BuildTarget.Android) { BuildNumberHolder.IncreaseBuildNumber(); } }
public static void IncreaseBuildNumber() { #if UNITY_EDITOR BuildNumberHolder holder = Instance; holder.mBuildNumber++; string version = UnityEditor.PlayerSettings.bundleVersion; int lastDot = version.LastIndexOf('.'); version = version.Remove(lastDot); version += "." + holder.mBuildNumber.ToString(); UnityEditor.PlayerSettings.bundleVersion = version; UnityEditor.PlayerSettings.Android.bundleVersionCode = holder.mBuildNumber; UnityEditor.PlayerSettings.iOS.buildNumber = holder.mBuildNumber.ToString(); // Force an asset save UnityEditor.EditorUtility.SetDirty(holder); UnityEditor.AssetDatabase.SaveAssets(); #endif }