Version: 2019.2
Написание кода для Android
Building and using plug-ins for Android

Advanced Unity mobile scripting

Device properties

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

Anti-piracy check

To get licensing information about users and prevent piracy, Google offers a service called Google Play Application Licensing. See the Google Play Application License Verification example plug-in on the Asset Store for an example of how you can integrate this functionality into your Unity application. You can also download the plug-in source code from its GitHub repository.

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.

Написание кода для Android
Building and using plug-ins for Android