Guest User

Untitled

a guest
May 27th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEditor.Build;
  3. using UnityEditor.Build.Reporting;
  4. using UnityEditor;
  5.  
  6. public class IncrementBuildNumber : IPreprocessBuildWithReport
  7. {
  8. public int callbackOrder { get { return 0; } } // Part of the IPreprocessBuildWithReport interface
  9.  
  10. public void OnPreprocessBuild(BuildReport report)
  11. {
  12. if (report.summary.platform == BuildTarget.iOS) // Check if the build is for iOS
  13. {
  14. // Increment build number if proper int, ignore otherwise
  15. int currentBuildNumber;
  16. if (int.TryParse(PlayerSettings.iOS.buildNumber, out currentBuildNumber))
  17. {
  18. string newBuildNumber = (currentBuildNumber + 1).ToString();
  19. Debug.Log("Setting new iOS build number to " + newBuildNumber);
  20. PlayerSettings.iOS.buildNumber = newBuildNumber;
  21. }
  22. else
  23. {
  24. Debug.LogError("Failed to parse build number " + PlayerSettings.iOS.buildNumber + " as int.");
  25. }
  26. }
  27. }
  28. }
Add Comment
Please, Sign In to add comment