Skip to content

Instantly share code, notes, and snippets.

@sanukin39
Created June 27, 2016 14:55
Show Gist options
  • Save sanukin39/adb7d0316b11163f2d47f13e62226702 to your computer and use it in GitHub Desktop.
Save sanukin39/adb7d0316b11163f2d47f13e62226702 to your computer and use it in GitHub Desktop.
Unity BuildPipeline.BuildPlayer sample
using UnityEngine;
using UnityEditor;
using System.IO;
using System.Linq;
using System.Collections;
public class BatchBuild {
// Android ビルド
[MenuItem("Build/Android")]
static void AndroidBuild(){
// 有効なシーン一覧のパスを取得
var scenes = EditorBuildSettings.scenes.Where(s => s.enabled).Select(s => s.path).ToArray();
// 出力用のファイルを定義
var outputFile = Application.dataPath + "/../androidBuild.apk";
if(File.Exists(outputFile)){
File.Delete(outputFile);
}
var target = BuildTarget.Android;
var options = BuildOptions.None;
BuildPipeline.BuildPlayer(scenes, outputFile, target, options);
}
// iOSビルド
[MenuItem("Build/iOS")]
static void iOSBuild(){
// 有効なシーン一覧のパスを取得
var scenes = EditorBuildSettings.scenes.Where(s => s.enabled).Select(s => s.path).ToArray();
// 出力用のフォルダを設定
var outputFile = Application.dataPath + "/../XcodeProject";
if(Directory.Exists(outputFile)){
Directory.Delete(outputFile, true);
}
var target = BuildTarget.iOS;
var options = BuildOptions.None;
BuildPipeline.BuildPlayer(scenes, outputFile, target, options);
}
}
@shrinath-kopare
Copy link

Thank you for this.

@andy3317
Copy link

Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment