Building games for Android devices requires an approach similar to that for iOS development. However, the hardware is not completely standardized across all devices, and this raises issues that don’t normally appear during development for iOS.
You need to have your Android development environment set up before testing your Unity applications on your Android device. Setting up your Android development environment involves the following steps:
Download and install the Java Development Kit (JDK).
Download and install the Android Software Development Kit (SDK) with the relevant Android platforms, platform tools and build tools for your Project.
Connect your device to your computer. The setup process differs for Windows and macOS, and is explained in detail on the Android developer website. Refer to your device manufacturer for specific information about connecting it to your computer.
Download and install the Android Native Development Kit (NDK) if you are using the IL2CPP scripting back end.
The Unity Manual contains a basic outline of the tasks that must be completed before you are able to run code on your Android device, or in the Android emulator. However, the best thing to do is follow the instructions step-by-step from the Android developer portal.
Unity verifies your development environment when building for Android, and prompts you to upgrade or download missing components if necessary. Always use the latest tools available unless a specific version is required by Unity.
Unity provides scripting APIs to access various input data and settings from Android devices.
Refer to the Android scripting page of the Manual for more information.
可使用插件直接从 C# 脚本调用使用 C/C++ 编写的 Android 函数(可间接调用 Java 函数)。
To find out how to make these functions accessible from within Unity, visit the Android plug-ins page.
Unity 支持遮挡剔除,这是一种对移动平台非常有价值的优化方法。
Refer to the Occlusion Culling Manual page for more information.
The splash screen displayed while the game launches is customizable on Android.
Refer to the Customizing an Android Splash Screen Manual page for more information.
The Android troubleshooting guide helps you discover the cause of bugs as quickly as possible. If, after consulting the guide, you suspect the problem is being caused by Unity, file a bug report following the Unity bug reporting guidelines.
See the Android bug reporting page for details about filing bug reports.
ETC is the standard texture compression format on Android.
所有当前的 Android 设备都支持 ETC1 版本,但该版本不支持具有 Alpha 通道的纹理。所有支持 OpenGL ES 3.0 的 Android 设备都支持 ETC2 版本。该版本可提供改进的 RGB 纹理质量,并且还支持具有 Alpha 通道的纹理。
默认情况下,Unity 对压缩的 RGB 纹理使用 ETC1,而对压缩的 RGBA 纹理使用 ETC2。如果 Android 设备不支持 ETC2,则纹理将在运行时解压缩。这会对内存使用产生影响,也会影响渲染速度。
DXT、PVRTC、ATC 和 ASTC 全都支持具有 Alpha 通道的纹理。这些格式还支持更高的压缩率和/或更好的图像质量,但仅在一部分 Android 设备上受支持。
可针对这些格式中的每种格式创建单独的 Android 分发存档 (.apk),并让 Android Market 的过滤系统为不同的设备选择正确的存档。
Movie textures are not supported on Android, but full-screen streaming playback is provided via scripting functions.
To learn about supported file formats and scripting API, consult the Movie Texture page or the Android supported media formats page.
2017–05–25 Page published with editorial review
5.5 版中的更新功能