Unity3d integration with android

后端 未结 2 1820
借酒劲吻你
借酒劲吻你 2020-12-07 09:55

I need to create an android application which consists of parts written on Unity3d (animation and so on) and on AndroidSDK (by androidSDK I mean few activities written in ja

2条回答
  •  再見小時候
    2020-12-07 10:32

    For fully supporting on Android, you don't need to create some middle-level code on java.

    Instead, you should:

    1. Create a Lib Project on Android SDK.
    2. Create 1 main Activity Extends UnityPlayerActivity
    3. Create others Activities that you need and add it into Manifest.
    4. Create resource, layout…
    5. Export to JAR and add it into Unity by copy all JAR, resource file to Assets/Plugins/Android folder.

    This method is helpful for writing Push notification, in app billing, etc…

    Ref# here: http://docs.unity3d.com/Documentation/Manual/PluginsForAndroid.html (-> Extending the UnityPlayerActivity Java Code)

    And in addition, by using below code:

    AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); 
    AndroidJavaObject activity = unityPlayer.GetStatic("currentActivity");
    activity.Call("yourFunctionName", parameters);
    

    You can do most of magic things with Android on Unity

    Note*: yourFunctionName must be implemented inside your main activity which extend from UnityPlayerActivity (Look at step 2)

    Regards,

提交回复
热议问题