由于 Google Play 游戏电脑版提供标准的 Android 运行时环境,因此除了确保您包含 x86 或 x86-64 二进制文件外,为移动设备或电脑打包游戏之间没有区别。如果可能,您应该在电脑上使用与移动版本相同的 APK 或应用包。
在移动设备和 Google Play 游戏电脑版之间使用一个软件包时,最好通过检测键盘是否存在在运行时启用 Google Play 游戏电脑版特定功能。
Kotlin
val hasKeyboard = resources.configuration.keyboard == KEYBOARD_QWERTY
Java
boolean hasKeyboard = getResources().getConfiguration().keyboard == KEYBOARD.QWERTY
C#
var unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
var currentActivity = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity");
var resources = currentActivity.Call<AndroidJavaObject>("getResources");
var configuration = resources.Call<AndroidJavaObject>("getConfiguration");
var keyboard = configuration.Get<int>("keyboard");
var hasKeyboard == 2; // Configuration.KEYBOARD_QWERTY
或者检查"com.google.android.play.feature.HPE_EXPERIENCE"
系统功能
Kotlin
var isPC = packageManager.hasSystemFeature("com.google.android.play.feature.HPE_EXPERIENCE")
Java
PackageManager pm = getPackageManager(); boolean isPC = pm.hasSystemFeature("com.google.android.play.feature.HPE_EXPERIENCE")
C#
var unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); var currentActivity = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity"); var packageManager = currentActivity.Call<AndroidJavaObject>("getPackageManager"); var isPC = packageManager.Call<bool>("hasSystemFeature", "com.google.android.play.feature.HPE_EXPERIENCE");