Created
June 27, 2016 14:55
-
-
Save sanukin39/adb7d0316b11163f2d47f13e62226702 to your computer and use it in GitHub Desktop.
Unity BuildPipeline.BuildPlayer sample
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 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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for this.