android - 有没有办法将 UnityPlayerActivity 用作 AppcompatActivity?

标签 android unity3d

我正在使用 android studio 制作统一插件,但这里有问题。一些 SDK 提供仅使用 AppcompatActivity 来制作 fragment 但我的MainActivity , 正是 UnityPlayerActivity不是 AppCompatActivity .所以它会导致错误......任何人都可以解决这个问题?

最佳答案

如果不了解您尝试与之交互的 SDK 的更多信息,就很难确切地告诉您如何解决您的问题。但是,有关这些类(class)的一些背景信息可能会对您有所帮助:UnityPlayerActivity是 Android 的 Activity 的子类类(class)。这是用于现代 Android Activity 的主要类。AppCompatActivity也是 Activity 的子类类,旨在让您在较旧的 Android 设备上使用某些功能(例如 fragment )。来自 the docs :

Base class for activities that wish to use some of the newer platform features on older Android devices. Some of these backported features include:

  • Using the action bar, including action items, navigation modes and more with the setSupportActionBar(Toolbar) API.
  • Built-in switching between light and dark themes by using the Theme.AppCompat.DayNight theme and AppCompatDelegate.setDefaultNightMode(int) API.
  • Integration with DrawerLayout by using the getDrawerToggleDelegate() API.

所以在OO方面:
  • UnityPlayActivity是一个 Activity
  • AppCompatActivity是一个 Activity
  • UnityPlayActivity不是 AppCompatActivity (他们有 sibling 关系)。

  • 如果您绝对需要AppCompatActivity , 处理此问题的一种方法是修改 UnityPlayActivity代码扩展AppCompatActivity反而。您可以see an example of that here .

    关于android - 有没有办法将 UnityPlayerActivity 用作 AppcompatActivity?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55275867/

    相关文章:

    Android 从屏幕截图中排除 View

    c# - 如何使 Unity 单例基类支持泛型?

    c# - 如何在 Unity3D 中使用 GameObject.Find (""找到非事件对象?

    c# - 尝试访问二维数组 Unity c# 中的实例化对象。无法访问或更改元素?

    Android 字符集问题下载 utf-8 网页

    android - 各种 Android 设备的应用程序背景大小

    android - 为应用引擎端点对象化 OfyService NoClassDefFoundError

    android - 使用 Firebase 时防止内存泄漏的最佳方法

    c# - 用于 Unity3d 5.x 的极简主义 Python 服务器

    c# - 在菜单 View 中启用/禁用光标