简体   繁体   中英

Insert unity as in a subview in android and plug in

I have to build an android app in which I have to integrate unity player with an existing android application. I need to get values from a sensor and animate the gameObject in unity. Should I make a plugin using ndk or jni? Please help. I'm new to this. I have read the docs but I am confused.

You can choose to build an Android Studio project instead of an APK. To do this, select the "Google Android Project" checkbox from the android build settings.

This will give you a project with a main activity which is a UnityPlayerActivity. You can add/remove activities, views and do anything you want with the project. You should also be able to move the contents to another project and merge them. The important thing here is to keep all the libraries and resources Unity builds intact. This should all feel natural if you're familiar with Android Studio.

To pass data to/from Unity, you can use the AndroidJava* classes, which essentially allow you to call any Java code (from the OS libraries or your app package) as if you were using reflection API.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM