とあるプログラマの備忘録

都内某所に住むプログラマが自分用に備忘録を残すという趣旨のブログです。はてなダイアリーから移動しました!

【Unity】TileMapEditorで作ったデータをX-UniTMXで読み込ませる 其の2

5/19追記
X-UniTMXがil2cppでビルド出来ない現象を確認しましたのでこちらの記事は参考までにしてください。
最新のX-UniTMXであば対応されている可能性があります。

さて前回にマップの読み込みができたのですが、
今回はColliderの作成までしてみたいと思います。
これが出来れば簡易的な横スクロールアプリが作れるはずです。

そして、マップファイルを外だしに出来る事で
AssetBundleから新しいマップデータの読み込みも出来るので、
アップデート無しで新マップを追加したり夢がヒロガリングですね!!

マップ作成

とりあえずこんなマップを作成しました。

f:id:raharu0425:20150424113052p:plain

このマップに当たり判定を行うオブジェクトを付けて行きます。 f:id:raharu0425:20150424113255p:plain

名前は適当にGroundとでもしておきます f:id:raharu0425:20150424113329p:plain

Unityに読み込ませる

f:id:raharu0425:20150424113432p:plain

GenerateColliders / Prefabs?にチェックを入れて 作成するとColliderを持つオブジェクトができあがりました!!

f:id:raharu0425:20150424114503p:plain

キャラクターでも置いてみる

とりあえずデフォルトで入っているロボのアセット(2D)をインポートします。

f:id:raharu0425:20150424113802p:plain

これでCharacterRobotBoyのプレハブを探し画面上に起きます。

f:id:raharu0425:20150424113900p:plain

こんな感じ

このプレハブにはすでにコントローラーが入っているので置いただけで動くはずです。

カメラをフォローさせる

今のままではキャラクターが見きれてしまうので
X-UniTMX ExamplesについているCamera Folow2D スクリプトをカメラにアタッチします。

f:id:raharu0425:20150424114255p:plain f:id:raharu0425:20150424114308p:plain

実際に動かしてみる


TileMapEditorで作ったデータをX-UniTMXで読み込ませる - YouTube

いい感じです。
TileMapEditorで吐き出したxmlファイルをUnityにうまく取り込めました。
とここまで分かりやすく横スクロールつくってきましたが、
別に横スクロールゲームを作りたい訳じゃないので次はRPGマップを作りたいと思ってます。

【Unity】TileMapEditorで作ったデータをX-UniTMXで読み込ませる 其の1

5/19追記
X-UniTMXがil2cppでビルド出来ない現象を確認しましたのでこちらの記事は参考までにしてください。
最新のX-UniTMXであば対応されている可能性があります。

最近ゆに☆アニのリリース作業で全く更新が止まっていたブログですが
そろそろ次のアプリを作りたいのでその下調べでもやろうかと思っています。

前にCocos2d-xでTileMapEditorを使ってマップを読み込むってのをやっていたのですが、
Macで使えてかつUnityに取り込めるタイルマップエディタってのが良いのが無くて
TileMapEditorをなんとか使いたいなぁと思って調べてみました。

Cocos2dx 3.0 TielMapEditor Tieldを使ってマップを作成する - とあるプログラマの備忘録

tiledの使い方も書いた

2014/05/29 15:44

それでは早速

Unity2Dプロジェクトを作成する

特に説明の必要は無いですね。
今回のプロジェクトからUnity5.xを使用しています。

タイルマップエディタの最新版を取得

Tiled Map Editor f:id:raharu0425:20150422121439p:plain

このとき使用しているバージョンは0.11.0になります。

タイル画像を用意して、適当にタイルを置いて行く

f:id:raharu0425:20150422121523p:plain

32px x 32pxのタイルチップ画像を用意します。

その後適当に置いてゆきます。 設定は以下の通り

f:id:raharu0425:20150422121714p:plain

こんな感じでつくってみました

f:id:raharu0425:20150422121932p:plain

これをTileMap001.tmxとして保存しておきましょう。

X-UniTMXのをUnityにインポートする

タイル情報をいい感じにしてくれるX-UniTMXを入れます。

Chaoseiro / X-UniTMX / Downloads — Bitbucket

X-UniTMX v1.7.1.unitypackageが落ちてくるのでUnityにインポートします。

f:id:raharu0425:20150422122354p:plain

なんか色々入ってきていますが、とりあえず気にしないで置いておきます。

TileMap001.tmxを複製して拡張子xmlにする

f:id:raharu0425:20150422122853p:plain

xmlとタイルチップ画像をResource以下に入れる

f:id:raharu0425:20150422122902p:plain

必ずResource以下に入れないと行けません。

UnityのGameObject > Create Other > Tiled Game Mapでオブジェクトを作成する

f:id:raharu0425:20150422123137p:plain

そうするとこんなオブジェクトが作成されます

f:id:raharu0425:20150422123218p:plain

マップデータを読み込ませる

f:id:raharu0425:20150422123513p:plain

先ほどのxmlを読み込ませて、Reload XMLMAPを押下
(マテリアルにはDefaultSpriteMaterialをアタッチしておきます)

その後Import as static Tile Mapを押下するおと

f:id:raharu0425:20150422123618p:plain

読み込まれました!!!

今後当たり判定とかもう少し踏み入れて行きたいですが、
とりあえずMAPが読み込めてほっとしました。

Unity 指定時間ローカルプッシュ通知処理を書いてみた Android編

-- 8/26追記 今北工業さんが私の記事のtypoを修正してくださりました〜! こちらも参考にしてくださいm( )m

blog.livedoor.jp

今月末に引っ越しを控え案件のタスクを残したくないraharuです
さて、前回に引き続きUnityのNative連携のAndro編です。

流れとしてはAlarmManagerで登録
レシーバーで受信したらローカル通知を投げるという事をしたいだけなのにクソはまった。。

※まだAndroidPluginの作成環境が出来てない人はこちらの記事で環境を構築してください。

パッケージ名は自由ですが、
今回はnet.raharu.localnotifypluginです
これあとでAndroidManifestに使うので重要

java

localNotification.java

package net.raharu.localnotifyplugin;

import java.util.Calendar;

import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.unity3d.player.UnityPlayer;

public class localNotification {
    
    /**
    * 時間指定でローカル通知を投げる
    * @param message
    * @param unixtime
    * @param primary_key
    */
    public void sendNotification(String message, long unixtime, int primary_key) 
    {
        Log.i("Unity", "SendNotificationStart");
        
        // インテント作成
        Activity activity = UnityPlayer.currentActivity;
        Context context = activity.getApplicationContext();
        Intent intent = new Intent(context, NotificationReceiver.class);
        //渡す値
        intent.putExtra("MESSAGE", message);
        intent.putExtra("PRIMARY_KEY", primary_key);
        
        //10秒後にアラーム(デバック用)
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(System.currentTimeMillis());
        calendar.add(Calendar.SECOND, 10);
        
        PendingIntent sender = PendingIntent.getBroadcast(context,  primary_key, intent, PendingIntent.FLAG_UPDATE_CURRENT); 
        AlarmManager alarm = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
        alarm.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis() , sender);
    }
}

NotificationReceiver.java

package net.raharu.localnotifyplugin;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v4.app.NotificationCompat;

/**
 * レシーバー
 * 
 * @author raharu
 */
public class NotificationReceiver extends BroadcastReceiver{
    
    @Override
    public void onReceive(Context context, Intent intent) {
        
        //値の取得
        String message = intent.getStringExtra("MESSAGE");
        Integer primary_key = intent.getIntExtra("PRIMARY_KEY", 0);
        
        // intentからPendingIntentを作成
        PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
        
        // LargeIcon の Bitmap を生成
        final PackageManager pm = context.getPackageManager();
        ApplicationInfo applicationInfo = null;
        try {
          applicationInfo = pm.getApplicationInfo(context.getPackageName(),PackageManager.GET_META_DATA);
        } catch (NameNotFoundException e) {
          e.printStackTrace();
          return;
        }
        final int appIconResId = applicationInfo.icon;
        Bitmap largeIcon = BitmapFactory.decodeResource(context.getResources(), appIconResId);
         
        // NotificationBuilderを作成
        NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
        builder.setContentIntent(pendingIntent);
        builder.setTicker("通知がとどきました");  //ステータスバーに届くテキスト
        builder.setSmallIcon(appIconResId);           //アイコン
        builder.setContentTitle("タイトルだよ!!");       // タイトル
        builder.setContentText(message);              // 本文(サブタイトル)
        builder.setLargeIcon(largeIcon);              //開いた時のアイコン
        builder.setWhen(System.currentTimeMillis());  //通知に表示される時間(※通知時間ではない!)
        
        // 通知時の音・バイブ・ライト
        builder.setDefaults(Notification.DEFAULT_ALL);
        builder.setAutoCancel(true);
         
        // NotificationManagerを取得
        NotificationManager manager = (NotificationManager) context.getSystemService(Service.NOTIFICATION_SERVICE);
        // Notificationを作成して通知
        manager.notify(primary_key, builder.build());
    }
 
}

このパッケージをjarとしてエクスポートしてAssets/Plugin/Androidの直下に起きます。

Unity側

AndroidMnifest.xmlにレシーバーと権限を追加

<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="XXXXXXXXXXXX"
    android:installLocation="preferExternal"
    android:theme="@android:style/Theme.NoTitleBar"
    android:versionCode="1"
    android:versionName="1.0">
    <supports-screens
        android:smallScreens="true"
        android:normalScreens="true"
        android:largeScreens="true"
        android:xlargeScreens="true"
        android:anyDensity="true"/>

    <application
        android:icon="@drawable/app_icon"
        android:label="@string/app_name"
        android:debuggable="true">
        <activity android:name="com.unity3d.player.UnityPlayerNativeActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
            <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
        </activity>
        <meta-data
    android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
        #ここに通知されるレシーバーを登録する(パッケージ名+クラス名)
        <receiver android:name="net.raharu.localnotifyplugin.NotificationReceiver" android:process=":remote" />
    </application>
    <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="20" />
    <uses-feature android:glEsVersion="0x00020000" />

    <uses-permission android:name="android.permission.INTERNET" />
     #バイブレートの権限追加
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
</manifest>

こんな感じで呼び出せる

    #if UNITY_ANDROID
        AndroidJavaObject m_plugin = new AndroidJavaObject( "net.raharu.localnotifyplugin.localNotification");
        if (m_plugin != null){
            m_plugin.Call("sendNotification", "本文だよ!!!!", [unixtime], [unique_id]);
        }
    #endif

unixtimeは通知したい時間(今回は強制で10秒後にしてるけども。。)
第三引数はユニークな値を入れるとよし

これで時間指定したローカル通知が届くようになりました。

当たり前の事かも知れないけど一本アプリ作るのに
c# java obj-c phpと4言語扱うのに
mono eclipse xcode vimを言ったり来たりして段々今何言語書いてるのか分からなくなってくる。

ネイティブ連携は面倒くさいね!

参考にさせて頂きました

【Android】指定時間に処理を実行する【AlarmManager】 - アプリ開発者のチラシの裏

Android - スリープ時にもBroadcastを処理する方法 - Qiita

Unity ローカルプッシュ通知処理を書いてみた iOS編

iOS8からローカルプッシュ通知にもユーザー許可が必要になりました。
今迄のやり方だとローカル通知が遅れなくなってしまったので
起動時に認証ダイアログを表示させるようにします。

まずはAssets/Plugin/iOS以下に
LocalNotificationController.mmを作成します。
ソースはこんな感じで書きます

#import "iPhone_target_Prefix.pch"
#import "UnityAppController.h"

@interface LocalNotificationController : UnityAppController
+(void)load;
@end

@implementation LocalNotificationController
+(void)load
{
    extern const char* AppControllerClassName;
    AppControllerClassName = "LocalNotificationController";
}


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{

    [super application:application didFinishLaunchingWithOptions:launchOptions];
    float version = [[[UIDevice currentDevice] systemVersion] floatValue];
    if (version >= 8.0)
    {
        if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
            UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeSound categories:nil];
            [application registerUserNotificationSettings:settings];
        }
    }
    return YES;
}

@end

これで実機起動すれば認証ダイアログが出てくるはずです。(iOS8以上)

実際に通知を送ってみます。

using UnityEngine;
using System.Collections;

public class LocalNotifyScript : MonoBehaviour {


   void Start ()
    {
        addLocalPush ();
    }

    void addLocalPush ()
    {

        Debug.Log ("ローカル通知が走ります");
        #if UNITY_EDITOR
        #elif UNITY_ANDROID
        #else
        addLocalPushiOS();
        #endif
    }

    void addLocalPushiOS()
    {
        LocalNotification l = new LocalNotification();
        l.applicationIconBadgeNumber = 1;
        l.fireDate = System.DateTime.Now.AddSeconds(10);
        l.alertBody = "通知テストだよ!";
        NotificationServices.ScheduleLocalNotification(l);
    }

}

これを適当なGameObjectにアタッチします。

なかなか資料が見つからず四苦八苦しました。。。
安西先生、ネイティブ連携をサクサク書けるようになりたいです。。

参考にさせていただきましたm( )m

UnityのiOSでAppDelegateに処理を追加する - ほげほげ(仮)

[Unity] iOS8でローカル通知が動かない: ものづくりログ

Unityで作ったiOSアプリにObj-CでPush通知を載せてみた | 丸ノ内テックブログ

UnityでiOSのネイティブコードを呼び出す最も簡単でシンプルな方法 - C# → Objective-C

[備忘録]AppController.mmあたりをいじっている時のUnity4.1.5迄からUnity4.2以上に上げる時の注意 - Qiita

Unity4.6 uGUIでサイズ可変な共通ダイアログを作成する

こんなダイアログを作成するのですが、 中の文言がどの位になるのか分からないのでサイズを可変にならないといけません。 今回はuGUIをつかってこれを作成します。

f:id:raharu0425:20141213115227p:plain

素材を作成します

f:id:raharu0425:20141213115344p:plain

これを切り抜いて5つのパーツを作成します。

f:id:raharu0425:20141213115744p:plain

これに名前を付けてUnityに取り込みます。
※ここまでは別段NGUIとなんら変わりません。

Unityで組み立て

Canvasの下に親になるパネルを作成します

f:id:raharu0425:20141213120334p:plain

以後Anchor Presetsが肝心です。

f:id:raharu0425:20141213120546p:plain

赤い線のアンカーは親のUIに対して座標固定で表示するという事です。

以下はこの親のパネルの子として作成します

f:id:raharu0425:20141213121645p:plain

headerの作成

f:id:raharu0425:20141213121041p:plain

f:id:raharu0425:20141213121716p:plain

アンカーは親のパネルに対して中心上に固定ストレッチなしです。

footerの作成

f:id:raharu0425:20141213121302p:plain

f:id:raharu0425:20141213121823p:plain

こちらは中心下に固定ストレッチなし

bodyの作成

f:id:raharu0425:20141213121524p:plain

f:id:raharu0425:20141213121905p:plain

bodyは親サイズが変わったら可変してほしいので
中心の上下ストレッチをつけます。

これに他の部品も付ける

メッセージエリアは中心上下のストレッチ

タイトルラベルは中心上に固定

OKボタンは中心下に固定

完成するとこうなります。

この状態になれば上下ストレッチが可能なダイアログが完成します。


uGUIDialog - YouTube

これでbodyに例えばスクロール範囲を指定して中身をスクロールすることもできるので 多様的に使えるダイアログが完成しました。

この後OKボタンやCloseボタンに通知処理を書いて ボタン押下後の呼び出し処理などを追加するのですが、それはまた別の機会に。。

UnityPro+Github+Jenkins+DeployGateで自動ビルド&配布環境を作る その2

必要環境

Mac
UnityPro(有料)
github(アカウント作成&SSH認証済み)
Jenkins(無料)
DeployGate(無料)
iOS Developper契約済みアカウント(有料)

となりますUnityProが必要な理由はバッチモードで
メソッドを直接実行できるオプションがProのみ対応しているとのことです。

0からこの環境を整えるのは結構面倒かとおもいますが、
一応必須条件は上記条件になります。

やる事

・Unityでプロジェクトの作成
Githubで管理を行う
コマンドラインからビルドする
・Jenkinsの設定に追加
xcodeプロジェクトからipaファイルを作成
・DeployGateアップロードして配布開始

・Jenkinsの設定に追加

の前に必要なプラグインをインストールします。

Jenkinsの管理からプラグインの管理を選択します。

f:id:raharu0425:20141212102053p:plain

必要なプラグイン

DeployGate Plugin
GIT plugin
GitHub API Plugin
GitHub plugin
Xcode integration

どこまでデフォルトで入ってるのかわすれてしまいましたが、大体このプラグインが必要です。

以下Jenkinsの設定周りです

プロジェクト名を入れます。任意ですが分かりやすい名前をつけます

f:id:raharu0425:20141212111821p:plain

githubリポジトリURLとアカウントを入力する

f:id:raharu0425:20141212111910p:plain

このコマンドは前回の記事で作成したコマンドでprojectpathを${WORKSPACE}に変更した物です

f:id:raharu0425:20141212112039p:plain

以下xcodeビルド周りの設定になります

f:id:raharu0425:20141212112206p:plain

f:id:raharu0425:20141212112306p:plain

本当はxcodeビルドでipaファイル作成出来るはずなんですけどなぜかUnityプロジェクトは正常にipaファイルが吐き出されない!
どうしたJenkins!!しょうがないのでappからipaファイルを作成するコマンドを自前で用意し、
シェルで追加しておきます。

/usr/bin/xcrun -sdk iphoneos PackageApplication -v 
"${WORKSPACE}/iOSDevice/build/[.appファイルのパス]" -o 
"${WORKSPACE}/iOSDevice/build/[.ipaファイルの保存先のパス]"

f:id:raharu0425:20141212112317p:plain

先ほど吐き出したipaファイルを保存しておく

f:id:raharu0425:20141212112325p:plain

DeployGateのAPIKeyとユーザー名を入力します。
最後にアップロードするipaファイルのパスを入力します。

f:id:raharu0425:20141212112333p:plain

以上で設定は完了です。 正常にビルドが行われると成果物が保存されDeployGateにアップロードされます。

f:id:raharu0425:20141212113450p:plain

f:id:raharu0425:20141212113457p:plain

いくつかつまづくところもありますが、
最新ソースをpull > バッチモードでUnityBuild > xcodeprojectからipaを作成 > DeployGateにアップロードして配布までを自動化できました。

これで少しデバッガさんやプロジェクトメンバーへの配布も楽にできました。
なぜipaファイルがXcodeプラグインの設定で作成出来ないのかがちょっと気がかりですが、
この記事は以上で完了とします。

ご意見マサカリ等歓迎致します。

UnityPro+Github+Jenkins+DeployGateで自動ビルド&配布環境を作る その1

必要環境

Mac
UnityPro(有料)
github(アカウント作成&SSH認証済み)
Jenkins(無料)
DeployGate(無料)
iOS Developper契約済みアカウント(有料)

となりますUnityProが必要な理由はバッチモードで
メソッドを直接実行できるオプションがProのみ対応しているとのことです。

0からこの環境を整えるのは結構面倒かとおもいますが、
一応必須条件は上記条件になります。

やる事

・Unityでプロジェクトの作成
Githubで管理を行う
コマンドラインからビルドする
・Jenkinsの設定についか
xcodeプロジェクトからipaファイルを作成
・DeployGateアップロードして配布開始

という流れになります。

・Unityでプロジェクトの作成

どんなプロジェクトでもかまいません適当なプロジェクトを作成して保存しましょう。
一応文字でも真ん中に入れてビルドが成功した事が分かる程度の物で問題ありません
今回は前回作成した4.6のuGUIを試しているプロジェクトを使います。

Unity4.6 uGUI 入門 Canvas編 - とあるプログラマの備忘録

Githubで管理を行う(.gitignoreの設定)

Jenkinsで最新ソースをpullしてそれをビルドする事を目的としていますので
Githubリポジトリを作成します。
ここら辺のやり方は色々親切に書いてくれている記事がありますので適当に探してください。

UnityプロジェクトをGithubに上げる際に不必要なフォルダやファイルを上げない為に
.gitignoreを設定します(※設定はあくまで一例です)

##############
## unity
##############
[Ll]ibrary
[Tt]emp
[Oo]bj

##############
## Editor
##############
*.pidb
*.csproj
*.unityproj
*.booproj
*.svd
*.user
*.userprefs
*.suo
*.sln
LocalCache/

##############
## BuildResult
##############
Simulator/
iOSDevice/

##############
## Mac
##############
*.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db

ignoreを設定したら自分のリポジトリにpushしましょう。

コマンドラインからビルドする

さてここまで来たら早速Unityをコマンドライン上から実行してみます。
この時に使うのはまだgithub上のプロジェクトでは無く先ほど作成したプロジェクトをビルドします

$ /Applications/Unity/Unity.app/Contents/MacOS/Unity

私の環境だとこのパスにありますが個人の環境に合わせてください。
MacはUnityを複数個立ち上げる事が出来ません、既にUnityを開いている場合は閉じてから再実行してください。

これで起動したらならビルドを自動で行う為にプロジェクトに以下のファイルを追加します 名前はBuildBatchにしました

f:id:raharu0425:20141211174756p:plain

using UnityEngine;
using UnityEditor;

using System.Collections;

public class BuildBatch : MonoBehaviour {

    // build iOS app
    [UnityEditor.MenuItem("Tools/Build Project AllScene iOS")]
    private static void BuildiOS(){
        Debug.Log("##########iOS Build Start#########");
    }
}

このcsファイルを保存して以下のコマンドを実行します

$ /Applications/Unity/Unity.app/Contents/MacOS/Unity -quit -batchmode -projectPath [自分のプロジェクトのパス] -executeMethod BuildBatch.BuildiOS -logFile ~/build.log; cat ~/build.log

~/build.logの中に

####iOS Build Start

とロギングされていれば問題ありません。

先ほどのBuildBatch.csを以下に編集します

using UnityEngine;
using UnityEditor;

using System.Collections;

public class BuildBatch : MonoBehaviour {

    // build iOS app
    [UnityEditor.MenuItem("Tools/Build Project AllScene iOS")]
    private static void BuildiOS(){
        Debug.Log("##########iOS Build Start#########");

        // 全てのシーンを取得する
        EditorUserBuildSettings.SwitchActiveBuildTarget( BuildTarget.iPhone );
        string[] allScene = new string[EditorBuildSettings.scenes.Length];
        int i = 0;
        foreach( EditorBuildSettingsScene scene in EditorBuildSettings.scenes ){
            Debug.Log ("scenePath(" + i + ")" + scene.path);
            allScene[i] = scene.path;
            i++;
        }

        // オプションの設定
        BuildOptions opt = BuildOptions.SymlinkLibraries |
        BuildOptions.AllowDebugging |
        BuildOptions.ConnectWithProfiler |
        BuildOptions.Development;

        PlayerSettings.iOS.sdkVersion = iOSSdkVersion.DeviceSDK;
        // Identifierは個人の環境に合わせる
        PlayerSettings.bundleIdentifier = "jp.co.AnimeMiru";
        // バージョンも必要に合わせて変更する
        PlayerSettings.bundleVersion = "1.0.0";
        PlayerSettings.statusBarHidden = true;
        string errorMsg_Device = BuildPipeline.BuildPlayer( 
            allScene,
            "iOSDevice",
            BuildTarget.iPhone,
            opt
        );

        if (string.IsNullOrEmpty(errorMsg_Device)){
            Debug.Log ("##########Success iOS Device Build#########");
        } else {
            Debug.Log ("##########Failed iOS Device Build#########");
            Debug.Log (errorMsg_Device);
        }

        //シュミレーター用
        PlayerSettings.iOS.sdkVersion = iOSSdkVersion.SimulatorSDK;
        string errorMsg_Simulator = BuildPipeline.BuildPlayer(
            allScene, 
            "Simulator", 
            BuildTarget.iPhone, 
            opt
        );
        if (string.IsNullOrEmpty(errorMsg_Simulator)){
            Debug.Log ("##########Success Simulator Build#########");
        } else {
            Debug.Log ("##########Failed Simulator Build#########");
            Debug.Log (errorMsg_Device);
        }

    }
}

正常にビルドが行われるとプロジェクト内部に以下の様に出力されます。

f:id:raharu0425:20141211175226p:plain

以下のサイトを参考にさせていただきました有り難うございます。

UnityのビルドをJenkins氏に任せて楽したい。 - ともち屋 http://sassembla.github.io/Public/2013:01:31%2017-47-32/2013:01:31%2017-47-32.html

次回はJenkinsの設定とDeployGateの設定を行います