Last active
April 9, 2022 07:34
-
-
Save andrew-raphael-lukasik/36a30f0955d7cdc758e394dc4e7266bf to your computer and use it in GitHub Desktop.
Increase Build Number Automatically (Unity3d 2017.1.*)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SOURCE: https://gist.github.com/andrew-raphael-lukasik/36a30f0955d7cdc758e394dc4e7266bf | |
using System.Collections; | |
using UnityEngine; | |
using UnityEditor; | |
using UnityEditor.Build; | |
public class IncreaseBuildNumberAutomatically : IPreprocessBuild | |
{ | |
#region IPreprocessBuild implementation | |
public void OnPreprocessBuild ( BuildTarget target , string path ) | |
{ | |
IncreaseBuildNumbers(); | |
} | |
#endregion | |
#region IOrderedCallback implementation | |
public int callbackOrder { get { return 0; } } | |
#endregion | |
#region PRIVATE_METHODS | |
static void IncreaseBuildNumbers () | |
{ | |
try | |
{ | |
//update bundleVersion: | |
//bundleVersion expected format is "1.0.0" | |
string[] bundleVersionSplit = PlayerSettings.bundleVersion.Split( '.' ); | |
PlayerSettings.bundleVersion = bundleVersionSplit[ 0 ]+"."+bundleVersionSplit[ 1 ]+"."+( int.Parse( bundleVersionSplit[ 2 ] )+1 ); | |
//update buildNumber: | |
PlayerSettings.macOS.buildNumber = ( int.Parse( PlayerSettings.macOS.buildNumber )+1 ).ToString(); | |
Debug.Log( "build#: "+PlayerSettings.macOS.buildNumber ); | |
} | |
catch( System.Exception ex ) | |
{ | |
Debug.LogException( ex ); | |
} | |
} | |
#endregion | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment