Created
November 20, 2015 10:50
-
-
Save alexsorokoletov/531738ce8e5681437f6d to your computer and use it in GitHub Desktop.
Unity3d automation script for Android and iOS
This file contains 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; | |
using System.Collections.Generic; | |
using UnityEditor; | |
using UnityEngine; | |
public class CIEditorScript | |
{ | |
static string[] SCENES = FindEnabledEditorScenes (); | |
static string APP_NAME = "LuauUnity"; | |
static string TARGET_DIR = "target"; | |
[MenuItem ("Custom/CI/Build iOS")] | |
static void PerformIOSBuild () | |
{ | |
GenericBuild (SCENES, TARGET_DIR + "/ios/", BuildTarget.iOS, BuildOptions.None); | |
} | |
[MenuItem ("Custom/CI/Build Android")] | |
static void PerformAndroidBuild () | |
{ | |
GenericBuild (SCENES, TARGET_DIR + "/android/", BuildTarget.Android, BuildOptions.AcceptExternalModificationsToPlayer); | |
} | |
private static string[] FindEnabledEditorScenes () | |
{ | |
List<string> EditorScenes = new List<string> (); | |
foreach (EditorBuildSettingsScene scene in EditorBuildSettings.scenes) { | |
if (!scene.enabled) | |
continue; | |
EditorScenes.Add (scene.path); | |
} | |
return EditorScenes.ToArray (); | |
} | |
static void GenericBuild (string[] scenes, string target_dir, BuildTarget build_target, BuildOptions build_options) | |
{ | |
EditorUserBuildSettings.SwitchActiveBuildTarget (build_target); | |
string res = BuildPipeline.BuildPlayer (scenes, target_dir, build_target, build_options); | |
if (res.Length > 0) { | |
throw new Exception ("BuildPlayer failure: " + res); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment