集成到Android项目中的Unity(Vuforia)项目在启动时显示黑屏 [英] Unity (Vuforia) project integrated in Android project shows a black screen on startup

查看:1086
本文介绍了集成到Android项目中的Unity(Vuforia)项目在启动时显示黑屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的情况:



我创建了一个Android应用程序和一个使用Vuforia 7.0.47的AR Unity应用程序。
Android应用程序具有很多功能,其中一个功能是使用Unity和Vuforia进行的增强现实。



为了轻松添加并稍后替换在Android项目中的Unity项目中,我将Unity应用程序导出到Android Studio项目中并使其成为一个库。之后,我在Android项目中添加了.aar文件。



所有这些似乎都可以正常工作,因为我的Android项目能够检测UnityPlayerActivity并能够启动Intent。



我现在使用以下代码(正常的Intent)在Android应用程序中启动Unity应用:

  Intent intent = new Intent(this,UnityPlayerActivity.class); 
startActivity(intent);

我遇到的问题:



每当UnityPlayerActivity启动时,您会看到Unity初始屏幕,然后是黑屏,而不是AR的摄像头打开。



但是,当我将Unity项目构建到我的手机上,一切正常,就像将其导出到Android Studio项目并从那里运行时一样。



仅当将其作为库添加到我现有的Android项目中时,才会出现问题。



我使用/尝试过的教程和链接



为了从导出的项目创建库,我遵循以下教程:

解决方案

您需要从



ExportedAndroidStudioProject / libs / VuforiaWrapper.aar VuforiaWrapper.aar 文件中提取/ p>

并将其添加到您的应用中在您添加UnityGame.aar文件并将其作为依赖项添加到gradle中的同一目录中

 依赖项{
实现fileTree(dir:'libs',include:['* .jar'])
的实现(名称:'UnityGame',ext:'aar')
的实现(名称:'VuforiaWrapper',ext: 'aar')}

希望这对您有所帮助。
祝你好运


My situation:

I created an Android app and an AR Unity app that makes use of Vuforia 7.0.47. The Android app has lots of features, one of the features is the augmented reality made with Unity and Vuforia.

In order to easily include and later on replace the Unity project in the Android project, I exported the Unity app to an Android Studio project and made it a library. After that I added the .aar file inside my Android project.

All of this seems to be working as my Android project is able to detect the UnityPlayerActivity and is able to start an Intent.

I now use the following code (a normal Intent) to start the Unity app inside my Android application:

Intent intent = new Intent(this, UnityPlayerActivity.class);
startActivity(intent);

The problem I have:

Whenever The UnityPlayerActivity starts, you see the Unity splash screen followed by a black screen instead of the camera opening for the AR.

However, when I build the Unity project to my phone everything works fine aswel as when exporting it to an Android studio project and running it from there.

The problem only seems to occur when including it as a library in my existing Android project.

Tutorials and links I used/tried

In order to create a library from the exported project I followed the following tutorial: https://medium.com/@davidbeloosesky/embedded-unity-within-android-app-7061f4f473a

The Logcat

This is the Logcat I get when starting the Intent

解决方案

You need to take VuforiaWrapper.aar file from

ExportedAndroidStudioProject/libs/VuforiaWrapper.aar

and add it to your app in the same directory where you added UnityGame.aar file and add it in gradle as a dependency

 dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation(name: 'UnityGame', ext:'aar')
implementation(name: 'VuforiaWrapper', ext:'aar')}   

Hope this helps you. Good luck

这篇关于集成到Android项目中的Unity(Vuforia)项目在启动时显示黑屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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