Version: 2019.2
Поддержка игровых контроллеров на iOS
Optimizing Performance on iOS

Advanced iOS scripting

Device properties

Можно получить доступ к специфичным для устройств свойствам. Изучите следующие страницы справки SystemInfo.deviceUniqueIdentifier, SystemInfo.deviceName, SystemInfo.deviceModel и SystemInfo.operatingSystem.

Anti-piracy check

A common way of hacking an application is by removing the AppStore DRM protection and then redistributing it for free. Use Unity’s anti-piracy check to find out if your application was altered after it was submitted to the AppStore.

Check if your application is genuine (not hacked) with the Application.genuine property. This is useful to alert users they are using a hacked application, or to disable certain functions, if the property returns false.

Note: Application.genuineCheckAvailable should be used along with Application.genuine to verify that application integrity can be confirmed. Accessing the Application.genuine property is a resource-intensive operation and so you shouldn’t perform it during frame updates or other time-critical code.

Vibration support

You can trigger a vibration by calling Handheld.Vibrate. Devices without vibration hardware ignore this call.

Activity indicator

Mobile operating systems have built-in activity indicators you can use during slow operations. See the documentation on Handheld.StartActivityIndicator docs for examples.

Screen orientation

You can control the screen orientation of your application on both ios and Android devices. Detecting a change in orientation or forcing a specific orientation is useful for creating game behaviors that depend on how the user is holding the device.

Retrieve device orientation by accessing the Screen.orientation property. Orientation can be one of the following:

Идентификация Behavior
Portrait Устройство в портретном режиме, удерживающееся в вертикальном положении. Кнопка “домой” расположена снизу.
PortraitUpsideDown Устройство в портретном режиме, но “вверх ногами”, удерживающееся в вертикальном положении. Кнопка “домой” расположена сверху.
LandscapeLeft Устройство в ландшафтном режиме, удерживающееся в вертикальном положении. Кнопка “домой” расположена справа.
LandscapeRight Устройство в ландшафтном режиме, удерживающееся в вертикальном положении. Кнопка “домой” расположена слева.

Set Screen.orientation to one of the above orientations, or use ScreenOrientation.AutoRotation to control the screen orientation. When you enable auto-rotation, you can still disable some orientation on a case-by-case basis.

See the API documentation for Screen.autorotateToPortrait, Screen.autorotateToPortraitUpsideDown, Screen.autorotateToLandscapeLeft and Screen.autorotateToLandscapeRight for more information.

Determining device generation

Different device generations have varied performance and support different functionalities. Use the iOS.DeviceGeneration property to query the device’s generation.

See the iPhone Hardware Guide documentation for more information about different device generations, performance, and supported functionality.

Display cutout

On some displays, certain areas of the screen might be obscured or non-functional because of other hardware occupying that space. Use Screen.cutouts to return a list of bounding boxes surrounding each cutout.

iOS devices do not provide a native API to get the display cutout information, so the cutouts are hardcoded in the Xcode project for each available iOS device. You can modify existing data or add additional devices in the Unity Xcode project ReportSafeAreaChangeForView function, which is in the UnityView.mm file.

See the API documentation on Screen.cutouts for more information on using this function.

Поддержка игровых контроллеров на iOS
Optimizing Performance on iOS