如何从 Unity Player 返回到之前运行的 Android Activity? [英] How to return from Unity Player to previous running Android Activity?

查看:81
本文介绍了如何从 Unity Player 返回到之前运行的 Android Activity?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了与本主题中提到的相同的问题 将 Unity 与 Eclipse 集成:单击后退按钮,但建议的解决方案不起作用.

I have the same problem as mentioned in this topic Integrating Unity with Eclipse: Back Button Click but the suggested solutions didn't work.

我在原生 Android 应用程序中嵌入了一个 Unity 播放器.我可以毫无问题地启动 Unity Player,但现在我想使用后退按钮返回到我之前的活动.我已经尝试过 Unity 端的 Application.Quit 和 android 端的 finish() ,两者都关闭了整个应用程序.我还尝试从 Unity 上下文开始一个新的 Activity 但这也不起作用,我认为这是因为我使用片段.我的活动设置如下:

I have a Unity Player embedded in a Native Android Application. I can start the Unity Player without a problem but now I want to go back to my previous activity with the back button. I already tried Application.Quit from Unity side and finish() from android side, both closes the whole application. I also tried to start a new Activity from the Unity context but this doesn't work either, I think this is because I work with fragments. My Activity setup is as follows:

嵌入了多个片段的 MainActivity.其中两个包含列表,我可以从中启动一个新活动,该活动向我显示列表元素的详细视图.详细视图也是片段,您可以在其中向左和向右滑动到上一个/下一个元素(类似于 gmail 应用程序).在详细信息视图中,您可以启动 Unity 以对 qualcomm vuforia 框架进行一些增强.

MainActivity where several fragments are embedded. Two of them contain Lists from which I can start a new Activity which shows me detail views of the List elements. The detail views are also fragments in which you can swipe left and right to previous/next element (similar to gmail app). From within the detail view, you can start Unity to have some augmentations with the qualcomm vuforia framework.

到目前为止一切正常,但我无法从 UnityPlayer 返回到详细信息视图.

up to this point everything works, but I can not go back from the UnityPlayer to the details view.

有人知道如何实现这一目标吗?

Does anyone have any idea how to achieve this?

谢谢!

推荐答案

当你在 unity 活动中回退时,整个过程将被终止.因此,当您通过 android 活动启动统一活动时,请在不同的进程中启动统一活动.您可以通过在项目的 android manifest 文件中声明它来做到这一点.

When you back press in unity activity the whole process will be killed. Therefore when you are starting a unity activity through android activity , start unity activity in different process. You can do this by declaring this in android manifest file of project.

这篇关于如何从 Unity Player 返回到之前运行的 Android Activity?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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