Last active
April 11, 2019 08:20
-
-
Save zxzsaga/8e2297db211e831102e905f7f19de099 to your computer and use it in GitHub Desktop.
Unity CI Utility.
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
| using System; | |
| using System.Collections.Generic; | |
| using UnityEditor; | |
| public class CIUtility { | |
| private static string buildDir = "Build/CatsAndDogs"; | |
| public static void Build_iOS() { | |
| EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.iOS, BuildTarget.iOS); | |
| PlayerSettings.iOS.buildNumber = (int.Parse(PlayerSettings.iOS.buildNumber) + 1).ToString(); | |
| string[] scenes = FindEnabledBuildScenes(); | |
| var buildReport = BuildPipeline.BuildPlayer(scenes, buildDir, BuildTarget.iOS, BuildOptions.AcceptExternalModificationsToPlayer); | |
| if (buildReport.summary.totalErrors > 0) { | |
| throw new Exception("BuildPlayer failure: " + buildReport); | |
| } | |
| } | |
| private static string[] FindEnabledBuildScenes() { | |
| List<string> scenes = new List<string>(); | |
| foreach (var scene in EditorBuildSettings.scenes) { | |
| if (scene.enabled) { | |
| scenes.Add(scene.path); | |
| } | |
| } | |
| return scenes.ToArray(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment