Unity3d integration with android

后端 未结 2 1818
借酒劲吻你
借酒劲吻你 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:31

    Here is a tutorial on the basics of running Unity inside of a normal Android app.

    There is a great tutorial on running Unity inside of Android Views. Once you get this up and running you can start embedding scenes easily anywhere in your App.

    When you need to call into the Java Android app from Unity, you can add this code:

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

    And then you can call any method you want on your activity through the activity AndroidJavaObject. Something like this:

    activity.Call("yourFunctionName", parameters);
    

提交回复
热议问题