Version: 2017.4
在 iOS 上优化性能
使用内置性能分析器来衡量性能

iOS 特定优化

本页面详细介绍 iOS 部署所特有的优化。

脚本调用优化

Most of the functions in the UnityEngine namespace are implemented in C/C++. Calling a C/C++ function from a Mono script involves a performance overhead, so you can save about 1 to 4 milliseconds per frame using iOS Script Call optimization.

To access iOS Script Call optimization, navigate to the Player Settings window (menu: Edit > Project Settings > Player) and select the iOS icon (shown below).

iOS Icon - select this to access the iOS settings in the Player Settings window
iOS Icon - select this to access the iOS settings in the Player Settings window

Locate the Script Call Optimization setting in the _Other Settings section.

The options for this setting are:-

  • Slow and Safe - the default Mono internal call handling with exception support.
  • Fast but no exceptions - a faster implementation of Mono internal call handling. However, this doesn’t support exceptions and so should be used with caution. An app that doesn’t explicitly handle exceptions (and doesn’t need to deal with them gracefully) is an ideal candidate for this option.

Note: There is no performance benefit when using the IL2CPP scripting backend. However, we recommend using Fast but no exceptions on release builds to avoid undefined behaviour.

设置帧率

Unity iOS 允许您更改应用程序尝试执行其渲染循环的频率;默认情况下,此频率设置为 30 帧/秒。降低此数字可以节省电池电量,但当然这种节省将以减少帧更新为代价。相反,也可以增加帧率,使渲染优先于其他活动(如触摸输入和加速度计处理)。您需要尝试选择不同的帧率来确定帧率在具体情况下对游戏运行过程的影响。

例如,如果应用程序涉及繁重的计算或渲染,但只能维持 15 帧/秒的帧率,那么将所需的帧率设置为高于 15 将不会带来任何额外的性能。必须充分优化应用程序来支持更高的帧率。

要设置所需的帧率,请更改 Application.targetFrameRate

Tuning accelerometer processing frequency

If accelerometer input is processed too frequently then the overall performance of your game may suffer as a result. By default, a Unity iOS application will sample the accelerometer 60 times per second. You may see some performance benefit by reducing the accelerometer sampling frequency and it can even be set to zero for games that don’t use accelerometer input. You can change the accelerometer frequency from the Other Settings panel in the iOS Player Settings.


  • 2018–06–14 页面已修订并只进行了有限的编辑审查
在 iOS 上优化性能
使用内置性能分析器来衡量性能