Mobage Unity SDK(iOS) Quick Guide

Mobage Unity SDK(iOS) Summary

Mobage Unity SDK is a custom plugin for Unity3D by Mobage.The main function is to call Social API with c# when making game in Unity3D,such as get friends list, get user information,payment and so on. 

DevelopEnviroment

PC: MacOS X 10.8
Unity3D Pro 3.5.0
XCode 4.6
iOS SDK 5.1

File Structure

Mobage Unity SDK(iOS) Installation

Unity3D IDE Environment Setting

1.Open Unity3D IDE,Select Assets->Import Package-> Custom Package…Import MobageUnitySDK.unitypackage.

(If you have installed old version MobageUnitySDK,please delete it before this step.)


2.Select GameObject->CreateEmpty.Rename it with MobageCallback which is used to receive message from IOS.

3.In Hierarchys window , set MobageCallback as follow.Binding scripts,HelloMobage.cs,MobageCallback.cs,BalanceButton.cs.


4.Set the picture Mobage_top_left as follow.

5.Set parameters of MobageGUI as follow.

Unity3D IDE Build Setting

1.Set consumerKey ,consumerSecret and appId in HelloMobage.cs.


2.Select File->Build Setting…,Switch Platform to iOS,click Add Current.



3.Click Player Setting…and set as follow.
a. Set Bundle Identifier:
Region Mainland is cn.mobage.g+YourAppId (Test Appid 13000057)
Region Taiwang is tw.mobage.g+YourAppId (Test Appid 23000013)
b. Set TargetPlatForm with armv7
c. Set Stripping Level Disabled.


4.Click Build and Run,Unity3D will open XCode automatically,the rest operations will complete in Xcode.

  

Xcode Environment Setting

1.Right click the project,select Add File to Unity-iPhone,add directory of MobageSDKforiOS,as follow.

Through edit conf.json to set environment and appId.

{"platformEnv":"SANDBOX", "app_id":"13000057", "affcode":"1980000000"}


2.There is payment service in Mobage SDK,so we need add 
StoreKit by steps.Click the target of Unity-iPhone >select BuildPhases>LinkBinaryWithLibraries->add StoreKit.framework.


We need add all frameworks as follow.


3.Parameter Settings
a. Select Unity-IPhone->BuildSettings.Select the target of Unity-iPhone,switch Basic to All in Build Settings,Find Linking->Other Linker Flags,Add flag of –ObjC in Debug and Release. 



b.Select Unity-iPhone->info
Add URL Type and set the option URL Schemes :
Region Mainland is mobage-cn-appid
Region Taiwang is mobage-tw-appid 


4.In the generate xcode project,modify AppController.mm as follow.
a.Import header files

Modify UnityViewController

In the end of function intOpenEAGL_UnityCallback(UIWindow** window, int* screenWidth, int* screenHeight, int* openglesVersion),add code as follow.

Add functions onMBGCNCommunityLaunched and onMBGCNCommunityDismiss in UnityViewController. 

b. In the end of function (void)applicationDidEnterBackground:

(UIApplication*)application, 
add code as follow.

c. In the end of function (void)applicationWillEnterForeground:

(UIApplication *)application
add code as follow.

5.If you use the API of Remote Notification,please add code as follow

a. Import header files

b. For using Apple push notification service, we should edit the remote notification callback function as follow:

c. If you also want to run application from Apple Notification bar and get remote notification,we should edit the function as follow.

6.To ensure that set coding signing certificate Of iOS. Select and connect the device of iOS,compile and run. 

 Mobage Unity SDK Plugin Calling Process


PREVIOUS

Mobage Unity SDK(Android) Quick Guide

NEXT

How to Use the Bank and Economy