How to make Unity3D as an activity in Android Studio?

本秂侑毒 提交于 2019-12-11 06:47:59

问题


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.

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?

Thanks in advance.


回答1:


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:

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

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



来源:https://stackoverflow.com/questions/41533426/how-to-make-unity3d-as-an-activity-in-android-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!