Version: 2017.2
iOS
Unity iOS 基础知识

iOS 开发入门

为 iPhone 和 iPad 等设备构建游戏需要采用与桌面 PC 游戏不同的方法。与 PC 市场不同,您的目标硬件是标准化的,不像搭载专用显卡的计算机那么快速或强大。因此,您必须以稍微不同的方式为这些平台开发游戏。此外,iOS 版 Unity 中提供的功能与桌面 PC 版的功能略有不同。

设置 Apple 开发者帐户

不需要 Apple 开发者帐户也可以构建到这些设备;如果仅需要构建到您自己的设备来进行测试,任何 Apple ID 都是可以的。

但是,我们建议您在继续操作之前设置 Apple 开发者帐户,因为需要通过该帐户才能充分发挥 Unity 与 iOS 的潜能。设置帐户的过程包括建立团队、添加设备以及最终确定资源调配配置文件。所有这些设置都是通过 Apple 的开发者网站完成的。由于这是一个复杂的过程,我们提供了必须完成的任务的基本概要,可结合 Apple 的 iPhone 开发者门户网站上提供的逐步说明一起参考。

Unity XCode 项目

构建 Unity iOS 游戏时会生成 XCode 项目。必须使用该项目来签名、编译和准备游戏以进行分发。请参阅 Unity XCode 项目手册页以了解更多信息。

访问 iOS 功能

Unity 提供了大量脚本 API 来访问多点触控屏幕、加速度计、设备地理位置系统等等。可以在 iOS 脚本页面中找到有关脚本类的更多信息。

将原生 C、C++ 或 Objective-C 代码公开给脚本

Unity 允许直接从 C# 脚本调用以 C、C++ 或 Objective-C 编写的自定义本机函数。要了解如何绑定本机函数,请访问插件页面

准备应用程序进行应用内购

Unity iOS 运行时允许下载新内容,您可以使用此功能实现应用内购。请参阅可下载内容手册页以了解更多信息。

自定义启动画面

请参阅自定义启动画面页面以了解如何更改游戏启动时显示的图像。

故障排除和报告崩溃

如果在 iOS 设备上遇到崩溃问题,请参阅 iOS 故障排除页面以查看常见问题和解决方案的列表。如果在此处找不到解决方案,请提交崩溃问题的错误报告(菜单:Unity Editor 中的 __Help > Report A Bug__)。

Unity 的 iOS 和桌面平台目标有何不同

Statically typed JavaScript

Dynamic typing in JavaScript is always turned off in Unity when targetting iOS (this is equivalent to #pragma strict getting added to all your scripts automatically). Static typing greatly improves performance, which is especially important on iOS devices. When you switch an existing Unity project to the iOS target, you will get compiler errors if you are using dynamic typing. You can easily fix these either by using explicitly declared types for the variables that are causing errors or taking advantage of type inference.

音频压缩

Unity supports importing a variety of source format sound files. However when importing these files (with the exception of tracker files), they are always re-encoded to the build target format. By default, this format is Vorbis, though this can be overridden per platform to other formats (ADPCM, MP3 etc) if required. Mp3 playback offers a little better performance on iPhone compared with Vorbis playback.

PVRTC 取代 DXT 纹理压缩

Unity iOS 不支持 DXT 纹理。实际上,iPhone/iPad 设备本身支持 PVRTC 纹理压缩。请参阅纹理导入设置文档以了解有关 iOS 纹理格式的更多信息。

电影播放

MovieTextures are not supported on iOS. Instead, full-screen streaming playback is provided via scripting functions. To learn about the supported file formats and scripting API, consult the movie page in the manual.

iOS
Unity iOS 基础知识
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961