如何使Unity3D成为Android Studio中的活动? [英] How to make Unity3D as an activity in Android Studio?

查看:161
本文介绍了如何使Unity3D成为Android Studio中的活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近使用Unity3D开发了一个AR程序,并将其构建为移动应用程序.现在,我打算将Unity程序导入Android Studio,以便可以将其作为活动类.

I recently developed an AR program using Unity3D and built it as a mobile application program. Right now, I am planning to import the Unity program into Android Studio so that I can make it as an activity class.

例如,我创建了一个名为开始"的按钮,当用户点击开始"按钮时,该应用会打开Unity程序并激活相机.

For example, I create a button called 'Start' and when the user taps the 'Start' button, the app opens the Unity program where the camera is activated.

这可能吗?如果是这样,我应该怎么做才能做到这一点?

Is this possible? If so, what should I do to make this possible?

谢谢.

推荐答案

没有直接的方法,当您从Unity构建项目时,将生成一个apk文件,该文件将在启动时启动Unity活动/引擎

There is no direct way to do this, when you build your project from unity you will generate an apk file that will start the unity activity/engine at start

您有两种方法可以做到这一点:

you have two approaches to do this:

方法1 :将Android平台统一转换,并通过在构建设置窗口中选中Google Android Project复选框,将您的unity项目编译为android studio项目,这将为生成一个Android Studio项目您可以打开它并根据需要对其进行操作,然后将开始活动更改为您的活动,并在需要时启动统一活动

Approach 1: switch platform for android in unity and compile your unity project to android studio project by checking the Google Android Project check box from the build settings window, this will generate an Android Studio project for you and you can open it and manipulate it as you like and change the starting activity to yours and launch unity activity when you want

方法2 :在android studio中实现您的活动并将代码编译为jar或aar文件,并将其作为一个插件添加到unity中,现在您需要操纵Unity中的清单以自行启动从你的活动而不是团结的活动中

Approach 2: Implement your activity in android studio and compile your code to jar or aar file and add it to unity as a plugin, now you need to manipulate the manifest in Unity its self to start from your activity and not unity's activity

我不认为第二种方法可行,第一种更好 但是,这意味着您每次要在统一代码中进行编辑时都需要编译一个新项目,如果您的统一项目已完成,这将对您有用,否则,您需要处理编译而不是覆盖您的代码每次改变自我

I don't think the second way is that practical, the first is much better However, this means you need to compile a new project each time you want to edit something in the unity code, if your project in unity is finalized, this will work will for you, otherwise, you need to deal with compiling and not overriding your changes each time your self

这篇关于如何使Unity3D成为Android Studio中的活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆