Advanced Unity Mobile Scripting
iOS
Advanced iOS scripting
Determining Device Generation
Different device generations support different functionality and widely varying performance. You should query the device for its generation and decide which functionality should be disabled to compensate for slower devices.
You can retrieve device generation by accessing the iPhoneSettings.generation property. Generation can be one of the following:
- iPhone
- iPhone3G
- iPhone3GS
- iPhone4
- iPodTouch1Gen
- iPodTouch2Gen
- iPodTouch3Gen
- iPodTouch4Gen
- iPad1Gen
You can find more information about different device generations, performance and supported functionality in iPhone Hardware Guide.
Device Properties
There are a number of device specific properties that you can access:
iPhoneSettings.uniqueIdentifier | Unique device identifier. |
iPhoneSettings.name | User specified name for device. |
iPhoneSettings.model | Is it iPhone or iPod Touch? |
iPhoneSettings.systemName | Operating system. |
SystemInfo.operatingSystem | Operating system version. |
Anti-Piracy Check
It is not uncommon for pirates to hack applications from AppStore by removing Apple DRM protection and redistributing them for free. Unity iOS comes with anti-piracy check which allows you to determine if your application was altered after it was submitted to AppStore.
You can check if your application is genuine (not-hacked) by accessing iPhoneUtils.isApplicationGenuine property. If this property returns false you're free to notify user that he is using hacked application or you can disable access to some functions of your application.
Note: accessing iPhoneUtils.isApplicationGenuine property is reasonably expensive operation and you should never do it on a frame-to-frame basis.
Vibration Support
You can trigger iOS vibration by calling iPhoneUtils.Vibrate. However iPod Touch devices lack vibration hardware and will just ignore this call.
Standard Assets
"Standard Assets" is a folder with special meaning (same as "Plugins" and "Editor) and its content is compiled before all other scripts. You should keep your scripts in folders without special name.
Android
Advanced iOS scripting
Determining Device Generation
Different Android devices support different functionality and widely varying performance. You should target specific devices or device families and decide which functionality should be disabled to compensate for slower devices. There are a number of device specific properties that you can access to figure out the device.
Note: Android Marketplace does some additional compatibility filtering, so you should not bother that your ARMv7 only app optimized for OGLES2 is offered to some old slow devices.
Device Properties
iPhoneSettings.uniqueIdentifier | Unique device identifier. |
iPhoneSettings.model | Is it iPhone or iPod Touch? |
iPhoneSettings.systemName | Operating system. |
SystemInfo.operatingSystem | Operating system version. |
Anti-Piracy Check
It is not uncommon for pirates to hack applications by removing Apple DRM protection and redistributing them for free. Unity Android comes with anti-piracy check which allows you to determine if your application was altered after it was submitted to AppStore.
You can check if your application is genuine (not-hacked) by accessing iPhoneUtils.isApplicationGenuine property. If this property returns false you're free to notify user that he is using hacked application or you can disable access to some functions of your application.
Note: iPhoneUtils.isApplicationGenuineAvailable should be used along with iPhoneUtils.isApplicationGenuine to verify that application integrity can actually be confirmed.
Note: accessing iPhoneUtils.isApplicationGenuine property is reasonably expensive operation and you should never do it on a frame-to-frame basis.
Vibration Support
You can trigger device vibration by calling iPhoneUtils.Vibrate. However devices lacking vibration hardware will just ignore this call.
Standard Assets
"Standard Assets" is a folder with special meaning (same as "Plugins" and "Editor) and its content is compiled before all other scripts. You should keep your scripts in folders without special name.