最近在准备一个手机游戏比赛,再看unityAndroid方面的一些知识,就看了看相关的东西,把重要的翻译了下来,给小组成员交流;
由于我之前一直使用印象笔记来做这些记录,但是印象笔记最近抽风了,笔记不止到为何不能分享,所以就这个机会把以前的笔记转移到博客上。
Getting Started with Android Development
开始我们的Android开发
Building games for a device running Android OS 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 occur in iOS development. There are some feature differences in the Android version of Unity just as there are with the iOS version.
创建一个在Android操作系统的设备上运行的游戏,其方法和在IOS上开发类似;然而,硬件标准不同的问题,则在IOS上不会出现。在unity的Android版本之间有一些明显的不同,就像ios一样。
Setting up your Android Developer environment
搭建你的Android开发环境
You will need to have your Android developer environment set up before you can test your Unity games on the device. This involves downloading and installing the Android SDK with the different Android plaforms and adding your physical device to your system (this is done a bit differently depending on whether you are developing on Windows or Mac).
你需要搭建好Android开发环境,在你开始在设备上测试你的游戏前。这包括下载和安装不同设备(版本?)的Android SDK,并且,添加你的物理设备到你的系统(这里有一点点的不同,在windows平台和MAC平台上)。
This setup process is explained on the Android developer website, and there may be additional information provided by the manufacturer of your device. Since this is a complex process, we’ve provided a
basic outline
of the tasks that must be completed before you can 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
.
这一步在Android开发者页面有解释,并且有额外的关于你硬件设备生产厂商的信息提供。因为这是一个复杂的过程,所以我们提供的是一个基本的必须被完成的框架,在你能够在Android手机或模拟器上运行代码之前。当然,最好的办法是跟着这个页面的介绍一步一步的做。
Access Android Functionality
访问Android功能
Unity Android provides scripting APIs to access various input data and settings. You can find out more about the available classes on the
Android scripting page.
Android提供的脚本API来访问各种数据的输入和设置。你可以在这个页面找到更多的类。
Exposing Native C, C++ or Java Code to Scripts
包含原生的C C++ 或者java代码到脚本中?雾
Unity Android allows you to call custom functions written in C/C++ directly from C# scripts (Java functions can be called indirectly). To find out how to make functions from native code accessible from Unity, visit the
Android plugins page.
unity Android允许你通过C#脚本调用,C/C++的函数(java的函数可以直接调用?)在下如下页面查看如何写函数使得原生代码在unity中可以被访问。
Occlusion Culling
Unity includes support for occlusion culling which is a particularly valuable optimization on mobile platforms. More information can be found on the
occlusion cullingpage.
Splash Screen Customization
开机画面定制
The splash screen displayed while the game launches can be customized - see
this page for further details.
在游戏开始时候的播放的画面可以被定制了,您可以再这个页面中查看相关类容。
Troubleshooting and Bug Reports
故障排除和报告问题
There are many reasons why your application may crash or fail to work as you expected. Our
Android troubleshooting guide will help you get to the bottom of bugs as quickly as possible. If, after consulting the guide, you suspect the problem is internal to Unity then you should file a bug report - see
this page for details on how to do this.
您的Android应用没能正常运行可能有很多的原因,我们的
Android troubleshooting guide可以帮助你尽快查找到相关的BUG测试。如果在您浏览过帮助界面之后,怀疑这个unity的内部问题,亦可以报告这个报告这个bug。
How Unity Android Differs from Desktop Unity
Android版unity和桌面版的不同
Strongly Typed JavaScript
强制类型转换的javaScript
For performance reasons, dynamic typing in JavaScript is always turned off in Unity Android, as if #pragma strict were applied automatically to all scripts. This is important to know if you start with a project originally developed for the desktop platforms since you may find you get unexpected compile errors when switching to Android; dynamic typing is the first thing to investigate. These errors are usually easy to fix if you make sure all variables are explicitly typed or use type inference on initialization.
出于性能考虑,javaScript的动态类型始终是关闭的,在Android 版unity中,好像严格的#pragma被自动应用到所有的脚本应用。这是非常重要的知道,如果你开始与最初开发用于桌面平台的项目,因为你可能会发现你切换到Android时意外编译错误;动态类型是你首先要研究的事情。这些错误通常是容易解决,如果你确保所有的变量都隐式类型或使用类型推断进行初始化操作。
ETC as Recommended Texture Compression
Although Unity Android does support DXT/PVRTC/ATC textures, Unity will decompress the textures into RGB(A) format at runtime if those compression methods are not supported by the particular device in use. This could have an impact on the GPU rendering speed and it is recommended to use the ETC format instead. ETC is the de facto standard compression format on Android, and should be supported on all post 2.0 devices. However, ETC does not support an alpha channel and RGBA 16-bit will sometimes be the best trade-off between size, quality and rendering speed where alpha is required.
ECT是被推荐的材质压缩方法
虽然unity Android版支持DXT/PVRTC/ATC材质,但是unity会解压纹理为RGB格式在运行时,i如果这些压缩方式不能被实际运行的设备支持的话。
It is also possible to create separate android distribution archives (.apk) for each of the DXT/PVRTC/ATC formats, and let the Android Market’s filtering system select the correct archives for different devices (see
this page for further details).
Movie Playback
Movie textures are not supported on Android, but a full-screen streaming playback is provided via scripting functions. To learn about supported file formats and scripting API, consult the
movie page or the
Android supported media formats page.