Building APK file in Unity (Below version 1.4.3)
|This page is based on latest Mobage Unity SDK 1.4.7 . For older version please see the archives .|
The goal of this chapter is to build an apk file in Unity IDE.
- Import Mobage Unity SDK assets and jar plugin generated in the previous chapter.
- Implement your Unity program.
you are expected to have completed the download, installation and license registration of Unity.
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.
|Notice that If the path to MobageUnitySDK,unitypackage has a multibyte character on Windows systems you will fail to import.|
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.)
The sample settings to show a button are now complete. When you press the replay icon at the top of the Unity IDE, the game preview screen is shown as below.
To perform login process, you are required to set a login listener that receives events from Mobage Unity SDK.
To use Mobage Unity SDK functions, please setup Plugins/Mobage/samples/Config.cs.
You will need to add AddCallback() method in the beginning of Awake() method from Mobage Unity SDK 1.4.7 .
Below is Awake() method example.
Call the initialize method on application start up like inside Awake() method.
Set the region, serverMode, consumerKey, consumerSecret, appId Arguments for MBGPlatform#Initialize.
|The consumerKey, consumerSecret, appId are provided when you register the application on Mobage Developers. Set the "Consumer Secret for SDK" and "Consumer Key for SDK" from "Android Application Settings" on Mobage Developers.|
To recieve Login status events you will need to add listener as below.
The following is a sample code to call MobagePeople.getCurrentUser().
Edit Plugins/Android/AndroidManifest.xml from Project view.
The folder tree is as below.
AndroidManifest.xml will be as below.
|Setting the MobageDashboardActivity's screenOrientation to landscape will show the Mobage UI in landscape.|
|Until May 28 2014, we requested to set launchMode to either singleTop or standard. For now on when using Unity SDK, please set the launchMode to singleTask.|
Please replace the following ID depending to your environment.
- Replace the to your App ID.
- Ex) 12009999
- Replace the to your App ID.
When selecting "File"->"Build Settings" in the Unity IDE (the lower left image), the Build Settings Window will open (the below image).
Select “Android” in “Platform” that is at the bottom-left of the Build Settings Window (the below image). Push ”Switch Platform” to configure Android platform settings.
When pushing ”Player Settings...”, UnityPlayer configuration pane will be shown in Unity IDE. Configure the following required settings.
When pressing the "Play Settings..." button, the setting items are shown in the Inspector view in the IDE window. Change "Other Settings" ->"Identification"->"Bundle Identifier" from the default value.
|If you do not change the Bundle identifier, you will not be able to build.|
|Please keep "Player Settings" -> "Stripping Level" as "Disabled" which is default settings. If you are planning to use other than the default setting please add the following on the link.xml under Assets|
When pressing the "Build" button at the bottom-right of the screen, a building process will start.
A dialog to set a path to Android SDK will be shown.
And then, a dialog to specify an apk file name will be shown (the below image).
Specify the apk file name and push the “Save” button. The apk file will be saved.
This apk file is the final output of the building process.
If you want to check the performance of the application, push “Build and Run” button at the bottom-right of “Build Settings” window.
- Updated documentation for Mobage Unity SDK 1.4.7
- Added How to Import Google Play service SDK.
- Added AndroidManifest. The launchMode has been set to singleTask as default.
- Initial Release.