Building Unity Plugin in Eclipse (versions older than 1.4)

In this chapter, we build a jar plugin that will be imported in Unity IDE.

Suppose you have already installed Android Eclipse Plugin in your Eclipse IDE.

Importing the template Eclipse project in Eclipse IDE

Import the Eclipse project that locates in the Mobage Unity SDK package with the name MobageUnitySDKforAndroid.

Editing AndroidManifest.xml

Edit the AndroidManifest.xml file as follows:

Please rewrite the following terms according to your environment.

  • ${YourActivityFQCN}:
    • Replace with the name of the Activity.
      • Ex) your.game.Activity
  • ${YourApplicationId} :
    • Replace with your application’s ID.
      • Ex) 12009999

Importing jar files in Eclipse IDE

Import the three jar libraries: MobageNativeSdk.jar, MobageUnityProxy.jar, and classes.jar in the project that is imported in the previous section. The file hierarchy on the Eclipse project looks like the upper right image.

[import classes.jar]

The file classes.jar is located in Unity IDE application folder. Copy classes.jar from the following path:

  • MAC
    • /Applications/Unity/Unity.app/Contents/PlaybackEngines/AndroidPlayer/bin/classes.jar
  • Windows
    • Unity/Editor/Data/PlaybackEngines/androidplayer/bin/classes.jar

Implementing login handlers

Because Mobage Unity SDK for Android doesn’t provide the C# interface for login handlings, you are required to implement login handlers as Java native codes. Immediately after your application is launched (for example, within onCreate()), invoke the initialization method with the arguments: a region type, an environment type, consumerKey, consumerSecret, an application ID and the root activity. The root activity is required to inherit the class UnityPlayerActivity. 

consumerKey and consumerSecret are issued when you register your application at the developer site. Please set "Consumer Key for SDK" and "Consumer Secret for SDK" values displayed in the "Android application settings" tab on the developer site.

 

After calling Mobage.initialize(), you are required to set a login listener in order to perform the authentication process. For the notifications of the login events to the Unity engine, invoke the methods that belong to the class UnityProxy as follows.

you should call addPlatformListener() either in onCreate() and onRestart() (below), or only in onStart() (sample code in the SDK).

Since the login listener is removed automatically when onStop is called, need not remove it explicitly.

Mobage.registerTick() is used to start a internal Timer and send events to event listeners asynchronously.

In addition, implement the following code to register the Mobage icon resources.

DON’T use R.java because Unity may replace the identifiers in R.java with other ones.

Generate jar plugin

Please perform the following steps to make a jar plugin for Unity.

[STEP 1] Select “File” --> “Export” on the upper menu.

[STEP 2] Select “Java” --> “JAR file” as the export type.

[STEP 3] JAR File Specification window will open. Select the resources that you want to export, input the JAR file name, and then, push “Finish” button.


Revision History

  • 08/08/2012
    • Initial Release.

Revision History

  • 08/14/2012
    • Initial Release.

PREVIOUS

Mobage Unity SDK for Android (Archives)

NEXT

Building Unity Plugin in Eclispe (version 1.4 or later)