什么是UnityPlayerActivity,UnityPlayerNativeActivity,UnityPlayerProxyActivity?

Chr*_*8er 10 android unity-game-engine

我对包含这三个文件的unity classes.jar感到困惑:UnityPlayerActivity,UnityPlayerNativeActivity,UnityPlayerProxyActivity.

  1. 你能帮我理解它们是如何工作的吗?他们有什么功能?

  2. 如果我通过统一编辑器在清单上将活动设置为UnityPlayerActivity,为什么Android可以找到我的插件?

小智 7

在安卓上

Android 上的活动就像 main() 函数 - 它是一个入口点。它代表具有用户界面的单个屏幕,就像用户与应用程序交互的窗口或框架。

检查它:https : //www.tutorialspoint.com/android/android_acitivities.htm https://developer.android.com/reference/android/app/Activity.html


本机活动是纯粹在本机代码中实现的活动。 Android NativeActivity https://developer.android.com/reference/android/app/NativeActivity.html


关于统一:

UnityPlayerActivity - 扩展 Android 的 Activity。

(已弃用) UnityPlayerNativeActivity - 扩展 NativeActivity。

(已弃用) UnityPlayerProxyActivity - 用作代理层以在 NativeActivity 和 Activity 之间自动切换。并选择了其中之一。


从 Unity 5 开始,UnityPlayerActivity是默认调用类。

当 UnityPlayerActivity 被调用时,它会启动 UnityPlayer 活动 which is nothing more than a FrameLayout that holds the SurfaceView where-with the help of OpenGL the actual game or app created in Unity will be drawn later on.

https://android.jlelse.eu/unity-and-android-connecting-the-dots-6368b31e86c5 - 强烈推荐这篇文章来了解 Unity 如何连接到 Android。


UnityPlayerNativeActivity是 Unity 4.5 和 4.6 中的默认活动。但是有不好的实现问题,所以再次切换到Activity。

要检查 Activity 和 NativeActivity 之间的差异,请查看 Android 文档中的差异。以及下一篇有趣的文章:

http://answers.unity3d.com/questions/853012/regarding-unitys-main-android-activity.html

就 UI 而言,本机活动与 SDK 活动


UnityPlayerProxyActivity - 是一个代理,在 Unity 3.x 中用于根据设备功能在 NativeActivity 和 Activity 之间切换。但现在,它不再使用了。

https://forum.unity.com/threads/androidmanifest-com-unity3d-player-unityplayerproxyactivity.285973/