简体   繁体   English

在Android的子视图中插入unity并插入

[英]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. 我必须构建一个Android应用程序,其中必须将Unity Player与现有的Android应用程序集成。 I need to get values from a sensor and animate the gameObject in unity. 我需要从传感器获取值并统一对gameObject进行动画处理。 Should I make a plugin using ndk or jni? 我应该使用ndk还是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. 您可以选择构建Android Studio项目而不是APK。 To do this, select the "Google Android Project" checkbox from the android build settings. 为此,请从android构建设置中选择“ Google Android Project”复选框。

This will give you a project with a main activity which is a UnityPlayerActivity. 这将为您提供一个主要活动为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. 这里重要的是保持Unity构建的所有库和资源完整无缺。 This should all feel natural if you're familiar with Android Studio. 如果您熟悉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. 要向Unity传递数据或从Unity传递数据,您可以使用AndroidJava *类,从本质上讲,您可以调用任何Java代码(从OS库或应用程序包中调用),就像使用反射API一样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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