您可以访问设备特有的许多属性。请参阅 SystemInfo.deviceUniqueIdentifier、SystemInfo.deviceName、SystemInfo.deviceModel 和 SystemInfo.operatingSystem 的脚本参考页面。
盗版者经常会破解应用程序(通过移除 AppStore DRM 保护),然后进行免费重新分发。Unity 附带反盗版检查功能,用于确定应用程序在提交到 AppStore 之后是否被篡改。
可以使用 Application.genuine 属性检查应用程序是否为正版(未被破解)。如果此属性返回 __false__,则可通知用户他们正在使用经过破解的应用程序,或者可以禁止他们访问应用程序的某些功能。
注意:应将 Application.genuineCheckAvailable 与 Application.genuine 结合使用来检查是否可以实际确认应用程序的完整性。访问 Application.genuine 属性是一项成本较高的操作,因此不应在帧更新期间或运行其他时间迫切的代码时执行该操作。
可通过调用 Handheld.Vibrate 来触发振动。但是,缺少振动硬件的设备将忽略此调用。
移动操作系统具有内置活动指示器,可在慢速操作期间使用这些指示器。请查看 Handheld.StartActivityIndicator 文档以了解示例用法。
Unity iOS/Android 允许您控制当前的屏幕方向。如果希望根据用户握持设备的方式来创建游戏行为,检测方向变化或强制使用某个特定方向会非常有用。
可通过访问 Screen.orientation 属性来获取设备方向。允许的方向如下:
Portrait | 设备处于纵向模式,直立握持设备,主屏幕按钮位于底部。 |
PortraitUpsideDown | 设备处于纵向模式,但是上下颠倒,直立握持设备,主屏幕按钮位于顶部。 |
LandscapeLeft | 设备处于横向模式,直立握持设备,主屏幕按钮位于右侧。 |
LandscapeRight | 设备处于横向模式,直立握持设备,主屏幕按钮位于左侧。 |
可通过将 Screen.orientation 设置为上述选项之一或设置为 ScreenOrientation.AutoRotation 来控制屏幕方向。 启用自动旋转时,仍然可根据具体情况禁用某个方向。请参阅 Screen.autorotateToPortrait、Screen.autorotateToPortraitUpsideDown、Screen.autorotateToLandscapeLeft 和 Screen.autorotateToLandscapeRight 的脚本参考页面
Different device generations support different functionality and have widely varying performance. You should query the device’s generation and decide which functionality should be disabled to compensate for slower devices. You can find the device generation from the iOS.DeviceGeneration property.
More information about different device generations, performance and supported functionality can be found in our iPhone Hardware Guide.
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.