Building Application in Unity
The goal of this chapter is to export an Xcode project in Unity IDE.
- Import Mobage Unity SDK assets.
- Implement your Unity program.
- Export your Unity project as an Xcode project.
![]() | you are expected to have completed the download, installation and license registration of Unity IDE. |
Import Mobage Unity SDK assets in Unity IDE
First, launch Unity and create a new Unity Project. While opening the newly created project, choose "Assets">"Import Package">"Custom Package..."
In the dialog that appears, specify a path to MobageUnitySDK.unitypackage.
Check all the options, and press the "Import" button at the right bottom to complete the import.
About F.O.X for Mobage
You can chose from below on the usage of F.O.X for Mobage from Mobage Unity SDK 1.4.7 .
- If you're planning to use F.O.X for Mobage, just follow the standard import procedure of the SDK.
- If you're planning to remove F.O.X for Mobage or implement F.O.X by yourself, remove "libmobage.a " from your Unity Project and add "libmobage-withoutfox.a" from Mobage Unity SDK.
- Remove "Assets/Plugins/iOS/libmobage.a" from you Unity Project.
- Copy "ios/SDKWithoutFOX/libmobage-withoutfox.a" from Mobage Unity SDK to "Assets/Plugins/iOS".
Open HelloMobage.unity
After importing the package, you can see the imported files in Project View.
Open a template asset to double click Plugins/HelloMobage.unity (Unity icon file) in the Project view. Then you can see the MobageCallback object in Hierarchy View.
(The following image shows the outline of the Project View with Wide layout.)
Configure MobageCallback object (Versions older than 1.4.3)
![]() | The following procedure is not needed for versions higher than Mobage Unity SDK 1.4.3 |
Configure the MobageCallback object by following the process below.
- Drag GUIs/MobageGUI and drop into "Missing(GUISkin)" that is at the right of "Custom Skin" in the top "Mono Behaviour" in the Inspector View.
- Drag Plugins/HelloMobage.cs (C# icon) into "Missing (Mono Script)" at the right of "Scripts", that is in the top "Mono Behavior".
- Drag Plugins/MobageCallback.cs (C# icon) into "Missing (Mono Script)" at the right of "Scripts" that is in the second “Mono Behaviour”.
- Configure the BalanceButton.
- Drop Plugins/BalancButton.cs into "Missing(Mono Script)" in "MonoBehavior".
- Drop GUIs/BalanceButton to "Missing (GUISkin)" at the right of "Custom Skin" in "MonoBehavior", where you have already set the above BalanceButton.cs.
![]() | If you click on the other elements before drag&drop, the Inspector View will be switched to another one. Before selecting MobageCallback in the Hierarchy View, open GUIs and Plugins in the Project View. |
Check the preview screen
Now you are ready to show the preview screen of the sample project. If you press the replay icon at the top of the Unity IDE window, the preview of game screen will be shown as below.
![]() | In the above preview screen, most of the buttons won’t work, because you can’t call Mobage Social APIs in the preview screen of Unity IDE. Please install your application in your iOS device if you want to check the behavior of the Mobage APIs. |
Edit C# codes to handle Mobage API events
You need to implement a login handler that receives login events from Mobage Unity SDK library to perform the login processes.
Implement MBGPlatform#initialization()
The following codes are required to handle the login events after launching the application, for example, in Awake().
MBGPlatform#initialization() is the initialization method and has the following arguments: a region type, an environment type, consumerKey, consumerSecret, and an application ID.
![]() | the above code has been already implemented in HelloMobage.cs. Please replace the three argument values, consumerKey, consumerSecret, and appId, with the issued values. They are shown in your application page on the Developer Site. |
Implement login callbacks
The following login callbacks are required for the arguments of addLoginListener().
![]() | the callbacks have also been already implemented in HelloMobage.cs. |
Building Xcode project
If you select "File"->"Build Settings" in the Unity IDE (the above image), the Build Settings Window will open (the below image).
Select “iOS” in “Platform” that is at the bottom-left of the Build Settings Window. And then, push ”Switch Platform” to configure iOS platform settings.
After pushing ”Player Settings...”, UnityPlayer configuration pane will be shown in the Inspector view in Unity IDE window (the below window).
Configure the following required settings.
Bundle Identifier configuration
Change "Other Settings"> "Identification">"Bundle Identifier" from the default value.
![]() | if you keep the Bundle identifier unchanged, you will not be able to build. |
![]() | Please keep "Player Settings" -> "Stripping Level" as "Disabled" which is default settings. Changing this value can cause instability to the Unity SDK. |
When you press the "Build and Run" button at the bottom-right of “Build Settings”
window, a building process will start. And then, Xcode IDE will be launched.
Revision History
- 08/08/2012
- Initial Release.