Getting Started with iOS Development Part5:iOS Scripting Advanced iOS scripting
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.