文档

Unity Engine

Unity Engine

GameActivity 要求和兼容性

Understand the system requirements and feature compatibility of the GameActivity application entry point.
阅读时间2 分钟最后更新于 1 个月前

GameActivity 具有以下依赖项:
  • CMake 构建系统
  • AndroidX

CMake

GameActivity 使用 CMake 在构建过程中生成桥接代码 (
libgame.so
)。
注意:如果您提供自定义 Android SDK,请确保该 SDK 包含 CMake 3.22.1。

AndroidX

GameActivity 需要以下 AndroidX Gradle 依赖项:
  • androidx.appcompat:appcompat
  • androidx.games:games-activity
  • androidx.core:core
  • Androidx.constraintlayout
Gradle 会自动安装 AndroidX 和这些依赖项。

插件兼容性

如果使用 GameActivity,应用程序的播放器循环将在原生线程(而非 Java 线程)上运行。这意味着从插件调用 myLooper 等 Java API 将失败。在
myLooper
的情况下,这是因为原生线程上不存在 Java 循环器。这也意味着任何依赖于此类 API(如
myLooper
)的 API 也会失败。例如,如果处理程序为 null,registerInputDeviceListener 将失败。创建 Android 插件时,了解此限制非常重要。

帧同步 (Choreographer)

如果使用 GameActivity,Unity 会尝试使用 NDK 编排器来同步帧时间。如果 Device API Level 低于 24,或者您的应用程序使用 32 位播放器并且 Device API Level 低于 29,Unity 将使用 Java 帧同步 (Choreographer)。

其他资源